Skip to content

AdaUrlComponents

Sanam edited this page Sep 23, 2026 · 1 revision

public readonly struct AdaUrlComponents : IEquatable<AdaUrlComponents>

Byte offsets of each part of a URL within AdaUrl.Href. Get it from AdaUrl.Components. Most code does not need this: the AdaUrl properties return each part directly.

Fields

Property Offset of
ProtocolEnd Just past the scheme and its colon
UsernameEnd Just past the username
HostStart The start of the host. Points at @ when credentials are present.
HostEnd Just past the host
Port Not an offset: the port number, or Omitted for the default port
PathnameStart The start of the path
SearchStart The ?, or Omitted
HashStart The #, or Omitted

For https://user:pass@example.com:8443/a/b?q=1#frag:

ProtocolEnd UsernameEnd HostStart HostEnd Port PathnameStart SearchStart HashStart
6 12 17 29 8443 34 38 42

Omitted

AdaUrlComponents.Omitted is uint.MaxValue and marks a missing part. Cast to int it becomes -1, which gives a wrong slice. Check first:

using var url = AdaUrl.Parse("http://example.com/"u8);
AdaUrlComponents c = url.Components;

if (AdaUrlComponents.IsPresent(c.SearchStart))
{
    // slice url.Href from c.SearchStart
}

Equality

==, !=, Equals and GetHashCode compare the offsets. Equal offsets do not mean equal URLs: nothing records where the path ends, so two URLs with the same scheme and host but different paths can compare equal. Compare AdaUrl.Href to compare URLs.

AdaHostType

public enum AdaHostType : byte, from AdaUrl.HostType.

Value Example host
Domain (0) example.com
IPv4 (1) 192.168.0.1
IPv6 (2) [::1]

AdaSchemeType

public enum AdaSchemeType : byte, from AdaUrl.SchemeType. All values except NotSpecial are WHATWG special schemes, which have default ports and normalised paths.

Value Scheme
Http (0) http
NotSpecial (1) Any other scheme, such as mailto or data
Https (2) https
Ws (3) ws
Ftp (4) ftp
Wss (5) wss
File (6) file

Clone this wiki locally