Table of Contents

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 Url

The 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

baseAddress Url

The base address to use.

relativeAddress string

The relative address to represent.

Url(string)

Creates a new Url from the given string.

public Url(string address)

Parameters

address string

The address to represent.

Url(string, string)

Creates a new Url from the given string.

[DomConstructor]
public Url(string url, string baseAddress = null)

Parameters

url string

The address to represent.

baseAddress string

The base address, if any.

Properties

Data

Gets the additional stored data of the URL. This is data that could not be assigned.

public string Data { get; }

Property Value

string

Fragment

Gets or sets the fragment, e.g., "first-section".

public string? Fragment { get; set; }

Property Value

string

Hash

Gets or sets the hash, e.g., "#first-section".

[DomName("hash")]
public string Hash { get; set; }

Property Value

string

Host

Gets or sets the host, e.g. "localhost:8800" or "www.w3.org".

[DomName("host")]
public string Host { get; set; }

Property Value

string

HostName

Gets or sets the host name, e.g. "localhost" or "www.w3.org".

[DomName("hostname")]
public string HostName { get; set; }

Property Value

string

Href

Gets or sets the hyper reference, i.e. the full URL.

[DomName("href")]
public string Href { get; set; }

Property Value

string

IsAbsolute

Gets if the stored url is absolute.

public bool IsAbsolute { get; }

Property Value

bool

IsInvalid

Gets if the URL parsing resulted in an error.

public bool IsInvalid { get; }

Property Value

bool

IsRelative

Gets if the stored url is relative.

public bool IsRelative { get; }

Property Value

bool

Origin

Gets the origin of the stored url.

[DomName("origin")]
public string? Origin { get; }

Property Value

string

Password

Gets or sets the password for authorization.

[DomName("password")]
public string? Password { get; set; }

Property Value

string

Path

Gets or sets the path, e.g. "mypath".

public string Path { get; set; }

Property Value

string

PathName

Gets or sets the pathname, e.g. "/mypath".

[DomName("pathname")]
public string PathName { get; set; }

Property Value

string

Port

Gets or sets the port, e.g. "8800".

[DomName("port")]
public string Port { get; set; }

Property Value

string

Protocol

Gets or sets the protocol, e.g. "http:".

[DomName("protocol")]
public string Protocol { get; set; }

Property Value

string

Query

Gets or sets the query part, e.g., "foo=bar".

public string? Query { get; set; }

Property Value

string

Scheme

Gets or sets the scheme, e.g. "http".

public string Scheme { get; set; }

Property Value

string

Gets or sets the search part, e.g., "?foo=bar".

[DomName("search")]
public string Search { get; set; }

Property Value

string

SearchParams

Obtains an advanced view on the provided query parameter.

[DomName("searchParams")]
public UrlSearchParams SearchParams { get; }

Property Value

UrlSearchParams

UserName

Gets or sets the username for authorization.

[DomName("username")]
public string? UserName { get; set; }

Property Value

string

Methods

Convert(Uri)

Creates an Url from an url transported in an Uri.

public static Url Convert(Uri uri)

Parameters

uri Uri

The 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 string

The 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 Url

The 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 object

The 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 Url

The Url to convert.

Returns

Uri

The Uri instance.