Class Url
- Namespace
- AngleSharp.Dom
- Assembly
- AngleSharp.dll
Represents an Url class according to RFC3986. This is the base for all internal Url manipulation. Specification for the API used from https://url.spec.whatwg.org/#api.
[DomName("URL")]
[DomExposed("Window")]
[DomExposed("Worker")]
public sealed class Url : IEquatable<Url>
- Inheritance
-
Url
- Implements
- Inherited Members
- Extension Methods
Constructors
Url(Url)
Creates a new Url by copying the other Url.
public Url(Url address)
Parameters
address
UrlThe address to copy.
Url(Url, string)
Creates a new absolute Url from the relative Url with the given base address.
public Url(Url baseAddress, string relativeAddress)
Parameters
Url(string)
Creates a new Url from the given string.
public Url(string address)
Parameters
address
stringThe address to represent.
Url(string, string)
Creates a new Url from the given string.
[DomConstructor]
public Url(string url, string baseAddress = null)
Parameters
Properties
Data
Gets the additional stored data of the URL. This is data that could not be assigned.
public string Data { get; }
Property Value
Fragment
Gets or sets the fragment, e.g., "first-section".
public string? Fragment { get; set; }
Property Value
Hash
Gets or sets the hash, e.g., "#first-section".
[DomName("hash")]
public string Hash { get; set; }
Property Value
Host
Gets or sets the host, e.g. "localhost:8800" or "www.w3.org".
[DomName("host")]
public string Host { get; set; }
Property Value
HostName
Gets or sets the host name, e.g. "localhost" or "www.w3.org".
[DomName("hostname")]
public string HostName { get; set; }
Property Value
Href
Gets or sets the hyper reference, i.e. the full URL.
[DomName("href")]
public string Href { get; set; }
Property Value
IsAbsolute
Gets if the stored url is absolute.
public bool IsAbsolute { get; }
Property Value
IsInvalid
Gets if the URL parsing resulted in an error.
public bool IsInvalid { get; }
Property Value
IsRelative
Gets if the stored url is relative.
public bool IsRelative { get; }
Property Value
Origin
Gets the origin of the stored url.
[DomName("origin")]
public string? Origin { get; }
Property Value
Password
Gets or sets the password for authorization.
[DomName("password")]
public string? Password { get; set; }
Property Value
Path
Gets or sets the path, e.g. "mypath".
public string Path { get; set; }
Property Value
PathName
Gets or sets the pathname, e.g. "/mypath".
[DomName("pathname")]
public string PathName { get; set; }
Property Value
Port
Gets or sets the port, e.g. "8800".
[DomName("port")]
public string Port { get; set; }
Property Value
Protocol
Gets or sets the protocol, e.g. "http:".
[DomName("protocol")]
public string Protocol { get; set; }
Property Value
Query
Gets or sets the query part, e.g., "foo=bar".
public string? Query { get; set; }
Property Value
Scheme
Gets or sets the scheme, e.g. "http".
public string Scheme { get; set; }
Property Value
Search
Gets or sets the search part, e.g., "?foo=bar".
[DomName("search")]
public string Search { get; set; }
Property Value
SearchParams
Obtains an advanced view on the provided query parameter.
[DomName("searchParams")]
public UrlSearchParams SearchParams { get; }
Property Value
UserName
Gets or sets the username for authorization.
[DomName("username")]
public string? UserName { get; set; }
Property Value
Methods
Convert(Uri)
Creates an Url from an url transported in an Uri.
public static Url Convert(Uri uri)
Parameters
uri
UriThe url to use.
Returns
- Url
The new Url.
Create(string)
Creates an Url from an absolute url transported in a string.
public static Url Create(string address)
Parameters
address
stringThe address to use.
Returns
- Url
The new Url.
Equals(Url?)
Determines whether the specified url is equal to the current object.
public bool Equals(Url? other)
Parameters
other
UrlThe url to compare with the current one.
Returns
- bool
True if the given url is equal to the current url, otherwise false.
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
- bool
True if the object is equal to the current object, otherwise false.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current url.
ToJson()
Serializes the URL string to a JSON compatible string representation.
[DomName("toJSON")]
public string ToJson()
Returns
- string
The currently stored url.
ToString()
Returns a string that represents the current url.
public override string ToString()
Returns
- string
The currently stored url.
Operators
implicit operator Uri(Url)
Converts the given Url to an Uri.
public static implicit operator Uri(Url value)
Parameters
value
UrlThe Url to convert.
Returns
- Uri
The Uri instance.