Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be a lot more precise when talking about URL component getter/setter #38029

Merged
merged 3 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions files/en-us/web/api/htmlanchorelement/hash/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ browser-compat: api.HTMLAnchorElement.hash

{{ APIRef("HTML DOM") }}

The **`HTMLAnchorElement.hash`** property returns a string containing a `'#'` followed by the fragment identifier of the URL.
The **`hash`** property of the {{domxref("HTMLAnchorElement")}} interface is a string containing a `"#"` followed by the fragment identifier of the `<a>` element's `href`. If the URL does not have a fragment identifier, this property contains an empty string, `""`.

The fragment is [percent-encoded](/en-US/docs/Glossary/Percent-encoding). If the URL does not have a fragment identifier, this property contains an empty string, `""`.
See {{domxref("URL.hash")}} for more information.

## Value

Expand Down
7 changes: 3 additions & 4 deletions files/en-us/web/api/htmlanchorelement/host/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ browser-compat: api.HTMLAnchorElement.host

{{ApiRef("HTML DOM")}}

The **`HTMLAnchorElement.host`** property is a
string containing the host, that is the _hostname_, and then,
if the _port_ of the URL is nonempty, a `':'`, and the _port_
of the URL.
The **`host`** property of the {{domxref("HTMLAnchorElement")}} interface is a string containing the host, which is the {{domxref("HTMLAnchorElement.hostname", "hostname")}}, and then, if the {{glossary("port")}} of the URL is nonempty, a `":"`, followed by the {{domxref("HTMLAnchorElement.port", "port")}} of the URL. If the URL does not have a `hostname`, this property contains an empty string, `""`.

See {{domxref("URL.host")}} for more information.

## Value

Expand Down
5 changes: 3 additions & 2 deletions files/en-us/web/api/htmlanchorelement/hostname/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ browser-compat: api.HTMLAnchorElement.hostname

{{ApiRef("HTML DOM")}}

The **`HTMLAnchorElement.hostname`** property is a
string containing the domain of the URL.
The **`hostname`** property of the {{domxref("HTMLAnchorElement")}} interface is a string containing either the {{glossary("domain name")}} or {{glossary("IP address")}} of the `<a>` element's `href`. If the URL does not have a hostname, this property contains an empty string, `""`. IPv4 and IPv6 addresses are normalized, such as stripping leading zeros, and domain names are converted to [IDN](https://en.wikipedia.org/wiki/Internationalized_domain_name).

See {{domxref("URL.hostname")}} for more information.

## Value

Expand Down
26 changes: 11 additions & 15 deletions files/en-us/web/api/htmlanchorelement/origin/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@ browser-compat: api.HTMLAnchorElement.origin

{{APIRef("HTML DOM")}}

The
**`HTMLAnchorElement.origin`** read-only property is a
string containing the Unicode serialization of the origin of the
represented URL.

That is:

- for URL using the `http` or `https`, the scheme followed by
`'://'`, followed by the domain, followed by `':'`, followed by
the port (the default port, `80` and `443` respectively, if
explicitly specified);
- for URL using `file:` scheme, the value is browser dependent;
- for URL using the `blob:` scheme, the origin of the URL following
`blob:`. E.g. `"blob:https://mozilla.org"` will have
`"https://mozilla.org".`
The **`origin`** read-only property of the {{domxref("HTMLAnchorElement")}} interface returns a string containing the Unicode serialization of the origin of the `<a>` element's `href`.

The exact structure varies depending on the type of URL:

- For URL using the `ftp:`, `http:`, `https:`, `ws:`, and `wss:` schemes, the {{domxref("HTMLAnchorElement.protocol", "protocol")}} followed by `//`, followed by the {{domxref("HTMLAnchorElement.host", "host")}}. Same as `host`, the {{domxref("HTMLAnchorElement.port", "port")}} is only included if it's not the default for the protocol.
- For URL using `file:` scheme, the value is browser dependent.
- For URL using the `blob:` scheme, the origin of the URL following `blob:`, but only if that URL uses the `http:`, `https:`, or `file:` scheme. For example, `blob:https://mozilla.org` will have `https://mozilla.org`.

For all other cases, the string `"null"` is returned.

See {{domxref("URL.origin")}} for more information.

## Value

Expand Down
11 changes: 6 additions & 5 deletions files/en-us/web/api/htmlanchorelement/password/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ browser-compat: api.HTMLAnchorElement.password

{{ApiRef("HTML DOM")}}

The **`HTMLAnchorElement.password`** property is a
string containing the password specified before the domain name.
The **`password`** property of the {{domxref("HTMLAnchorElement")}} interface is a string containing the password component of the `<a>` element's `href`. If the URL does not have a password, this property contains an empty string, `""`.

If it is set without first setting the
[`username`](/en-US/docs/Web/API/HTMLAnchorElement/username)
property, it silently fails.
This property can be set to change the password of the URL. If the URL has no {{domxref("HTMLAnchorElement.host", "host")}} or its scheme is `file:`, then setting this property has no effect.

The password is {{Glossary("Percent-encoding", "percent-encoded")}} when setting but not percent-decoded when reading.

See {{domxref("URL.password")}} for more information.

## Value

Expand Down
7 changes: 4 additions & 3 deletions files/en-us/web/api/htmlanchorelement/port/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ browser-compat: api.HTMLAnchorElement.port

{{ApiRef("HTML DOM")}}

The **`port`** property of the {{domxref("HTMLAnchorElement")}} interface is a string containing the port number of the URL, or the empty string if the port is the default for the protocol.
The **`port`** property of the {{domxref("HTMLAnchorElement")}} interface is a string containing the port number of the `<a>` element's `href`. If the port is the default for the protocol (`80` for `ws:` and `http:`, `443` for `wss:` and `https:`, and `21` for `ftp:`), this property contains an empty string, `""`.

> [!NOTE]
> If the {{domxref("HTMLAnchorElement")}} object refers to a URL that doesn't contain an explicit port number (e.g., `https://localhost`) or contains a port number that's the default port number corresponding to the protocol part of the URL (e.g., `https://localhost:443`), then the `port` property will be the empty string: `''`.
This property can be set to change the port of the URL. If the URL has no {{domxref("HTMLAnchorElement.host", "host")}} or its scheme is `file:`, then setting this property has no effect. It also silently ignores invalid port numbers.

See {{domxref("URL.port")}} for more information.

## Value

Expand Down
9 changes: 5 additions & 4 deletions files/en-us/web/api/htmlanchorelement/protocol/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ browser-compat: api.HTMLAnchorElement.protocol

{{ApiRef("HTML DOM")}}

The
**`HTMLAnchorElement.protocol`**
property is a string representing the protocol scheme of the URL,
including the final `':'`.
The **`protocol`** property of the {{domxref("HTMLAnchorElement")}} interface is a string containing the protocol or scheme of the `<area>` element's `href`, including the final `":"`. If the port is the default for the protocol (`80` for `ws:` and `http:`, `443` for `wss:` and `https:`, and `21` for `ftp:`), this property contains an empty string, `""`.

This property can be set to change the protocol of the URL. A `":"` is appended to the provided string if not provided. The provided scheme has to be compatible with the rest of the URL to be considered valid.

See {{domxref("URL.protocol")}} for more information.

## Value

Expand Down
10 changes: 7 additions & 3 deletions files/en-us/web/api/htmlanchorelement/search/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ browser-compat: api.HTMLAnchorElement.search

{{ApiRef("HTML DOM")}}

The **`HTMLAnchorElement.search`** property is a search
string, also called a _query string_, that is a string containing
a `'?'` followed by the parameters of the URL.
The **`search`** property of the {{domxref("HTMLAnchorElement")}} interface is a search string, also called a _query string_, that is a string containing a `"?"` followed by the parameters of the `<a>` element's `href`. If the URL does not have a search query, this property contains an empty string, `""`.

This property can be set to change the query string of the URL. When setting, a single `"?"` prefix is added to the provided value, if not already present. Setting it to `""` removes the query string.

The query is {{Glossary("Percent-encoding", "percent-encoded")}} when setting but not percent-decoded when reading.

Modern browsers provide
[`URLSearchParams`](/en-US/docs/Web/API/URLSearchParams/get#examples)
and
[`URL.searchParams`](/en-US/docs/Web/API/URL/searchParams#examples)
to make it easy to parse out the parameters from the query string.

See {{domxref("URL.search")}} for more information.

## Value

A string.
Expand Down
9 changes: 7 additions & 2 deletions files/en-us/web/api/htmlanchorelement/username/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ browser-compat: api.HTMLAnchorElement.username

{{ApiRef("HTML DOM")}}

The **`HTMLAnchorElement.username`** property is a
string containing the username specified before the domain name.
The **`username`** property of the {{domxref("HTMLAnchorElement")}} interface is a string containing the username component of the `<a>` element's `href`. If the URL does not have a username, this property contains an empty string, `""`.

This property can be set to change the username of the URL. If the URL has no {{domxref("HTMLAnchorElement.host", "host")}} or its scheme is `file:`, then setting this property has no effect.

The username is {{Glossary("Percent-encoding", "percent-encoded")}} when setting but not percent-decoded when reading.

See {{domxref("URL.username")}} for more information.

## Value

Expand Down
4 changes: 2 additions & 2 deletions files/en-us/web/api/htmlareaelement/hash/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ browser-compat: api.HTMLAreaElement.hash

{{ APIRef("HTML DOM") }}

The **`HTMLAreaElement.hash`** property returns a string containing a `'#'` followed by the fragment identifier of the URL.
The **`hash`** property of the {{domxref("HTMLAreaElement")}} interface is a string containing a `"#"` followed by the fragment identifier of the `<area>` element's `href`. If the URL does not have a fragment identifier, this property contains an empty string, `""`.

The fragment is not {{Glossary("Percent-encoding", "percent-encoded")}}. If the URL does not have a fragment identifier, this property contains an empty string, `""`.
See {{domxref("URL.hash")}} for more information.

## Value

Expand Down
7 changes: 3 additions & 4 deletions files/en-us/web/api/htmlareaelement/host/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ browser-compat: api.HTMLAreaElement.host

{{ApiRef("HTML DOM")}}

The **`HTMLAreaElement.host`** property is a
string containing the host, that is the _hostname_, and then,
if the _port_ of the URL is nonempty, a `':'`, and the _port_
of the URL.
The **`host`** property of the {{domxref("HTMLAreaElement")}} interface is a string containing the host, which is the {{domxref("HTMLAreaElement.hostname", "hostname")}}, and then, if the {{glossary("port")}} of the URL is nonempty, a `":"`, followed by the {{domxref("HTMLAreaElement.port", "port")}} of the URL. If the URL does not have a `hostname`, this property contains an empty string, `""`.

See {{domxref("URL.host")}} for more information.

## Value

Expand Down
4 changes: 3 additions & 1 deletion files/en-us/web/api/htmlareaelement/hostname/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ browser-compat: api.HTMLAreaElement.hostname

{{ApiRef("HTML DOM")}}

The **`HTMLAreaElement.hostname`** property is a string containing the domain of the URL.
The **`hostname`** property of the {{domxref("HTMLAreaElement")}} interface is a string containing either the {{glossary("domain name")}} or {{glossary("IP address")}} of the `<area>` element's URL. If the URL does not have a hostname, this property contains an empty string, `""`. IPv4 and IPv6 addresses are normalized, such as stripping leading zeros, and domain names are converted to [IDN](https://en.wikipedia.org/wiki/Internationalized_domain_name).

See {{domxref("URL.hostname")}} for more information.

## Value

Expand Down
26 changes: 11 additions & 15 deletions files/en-us/web/api/htmlareaelement/origin/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@ browser-compat: api.HTMLAreaElement.origin

{{APIRef("HTML DOM")}}

The
**`HTMLAreaElement.origin`** read-only property is a
string containing the Unicode serialization of the origin of the
represented URL.

That is:

- for URL using the `http` or `https`, the scheme followed by
`'://'`, followed by the domain, followed by `':'`, followed by
the port (the default port, `80` and `443` respectively, if
explicitly specified);
- for URL using `file:` scheme, the value is browser dependent;
- for URL using the `blob:` scheme, the origin of the URL following
`blob:`. E.g. `"blob:https://mozilla.org"` will have
`"https://mozilla.org".`
The **`origin`** read-only property of the {{domxref("HTMLAreaElement")}} interface returns a string containing the Unicode serialization of the origin of the `<area>` element's `href`.

The exact structure varies depending on the type of URL:

- For URL using the `ftp:`, `http:`, `https:`, `ws:`, and `wss:` schemes, the {{domxref("HTMLAnchorElement.protocol", "protocol")}} followed by `//`, followed by the {{domxref("HTMLAnchorElement.host", "host")}}. Same as `host`, the {{domxref("HTMLAnchorElement.port", "port")}} is only included if it's not the default for the protocol.
- For URL using `file:` scheme, the value is browser dependent.
- For URL using the `blob:` scheme, the origin of the URL following `blob:`, but only if that URL uses the `http:`, `https:`, or `file:` scheme. For example, `blob:https://mozilla.org` will have `https://mozilla.org`.

For all other cases, the string `"null"` is returned.

See {{domxref("URL.origin")}} for more information.

## Value

Expand Down
11 changes: 6 additions & 5 deletions files/en-us/web/api/htmlareaelement/password/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ browser-compat: api.HTMLAreaElement.password

{{ApiRef("HTML DOM")}}

The **`HTMLAreaElement.password`** property is a
string containing the password specified before the domain name.
The **`password`** property of the {{domxref("HTMLAreaElement")}} interface is a string containing the password component of the `<area>` element's `href`. If the URL does not have a password, this property contains an empty string, `""`.

If it is set without first setting the
[`username`](/en-US/docs/Web/API/HTMLAreaElement/username)
property, it silently fails.
This property can be set to change the password of the URL. If the URL has no {{domxref("HTMLAreaElement.host", "host")}} or its scheme is `file:`, then setting this property has no effect.

The password is {{Glossary("Percent-encoding", "percent-encoded")}} when setting but not percent-decoded when reading.

See {{domxref("URL.password")}} for more information.

## Value

Expand Down
2 changes: 2 additions & 0 deletions files/en-us/web/api/htmlareaelement/pathname/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ string containing an initial `'/'` followed by the path of
the URL not including the query string or fragment (or the empty string if there is no
path).

The pathname is {{Glossary("Percent-encoding", "percent-encoded")}} when setting but not percent-decoded when read.

## Value

A string.
Expand Down
7 changes: 4 additions & 3 deletions files/en-us/web/api/htmlareaelement/port/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ browser-compat: api.HTMLAreaElement.port

{{ApiRef("HTML DOM")}}

The **`port`** property of the {{domxref("HTMLAreaElement")}} interface is a string containing the port number of the URL, or the empty string if the port is the default for the protocol.
The **`port`** property of the {{domxref("HTMLAreaElement")}} interface is a string containing the port number of the `<area>` element's `href`. If the port is the default for the protocol (`80` for `ws:` and `http:`, `443` for `wss:` and `https:`, and `21` for `ftp:`), this property contains an empty string, `""`.

> [!NOTE]
> If the {{domxref("HTMLAreaElement")}} object refers to a URL that doesn't contain an explicit port number (e.g., `https://localhost`) or contains a port number that's the default port number corresponding to the protocol part of the URL (e.g., `https://localhost:443`), then the `port` property will be the empty string: `''`.
This property can be set to change the port of the URL. If the URL has no {{domxref("HTMLAnchorElement.host", "host")}} or its scheme is `file:`, then setting this property has no effect. It also silently ignores invalid port numbers.

See {{domxref("URL.port")}} for more information.

## Value

Expand Down
9 changes: 5 additions & 4 deletions files/en-us/web/api/htmlareaelement/protocol/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ browser-compat: api.HTMLAreaElement.protocol

{{ApiRef("HTML DOM")}}

The
**`HTMLAreaElement.protocol`**
property is a string representing the protocol scheme of the URL,
including the final `':'`.
The **`protocol`** property of the {{domxref("HTMLAreaElement")}} interface is a string containing the protocol or scheme of the `<area>` element's `href`, including the final `":"`. If the port is the default for the protocol (`80` for `ws:` and `http:`, `443` for `wss:` and `https:`, and `21` for `ftp:`), this property contains an empty string, `""`.

This property can be set to change the protocol of the URL. A `":"` is appended to the provided string if not provided. The provided scheme has to be compatible with the rest of the URL to be considered valid.

See {{domxref("URL.protocol")}} for more information.

## Value

Expand Down
10 changes: 7 additions & 3 deletions files/en-us/web/api/htmlareaelement/search/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ browser-compat: api.HTMLAreaElement.search

{{ApiRef("HTML DOM")}}

The **`HTMLAreaElement.search`** property is a search
string, also called a _query string_, that is a string containing
a `'?'` followed by the parameters of the URL.
The **`search`** property of the {{domxref("HTMLAreaElement")}} interface is a search string, also called a _query string_, that is a string containing a `"?"` followed by the parameters of the `<area>` element's `href`. If the URL does not have a search query, this property contains an empty string, `""`.

This property can be set to change the query string of the URL. When setting, a single `"?"` prefix is added to the provided value, if not already present. Setting it to `""` removes the query string.

The query is {{Glossary("Percent-encoding", "percent-encoded")}} when setting but not percent-decoded when reading.

Modern browsers provide
[`URLSearchParams`](/en-US/docs/Web/API/URLSearchParams/get#examples)
and
[`URL.searchParams`](/en-US/docs/Web/API/URL/searchParams#examples)
to make it easy to parse out the parameters from the query string.

See {{domxref("URL.search")}} for more information.

## Value

A string.
Expand Down
9 changes: 7 additions & 2 deletions files/en-us/web/api/htmlareaelement/username/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ browser-compat: api.HTMLAreaElement.username

{{ApiRef("HTML DOM")}}

The **`HTMLAreaElement.username`** property is a
string containing the username specified before the domain name.
The **`username`** property of the {{domxref("HTMLAreaElement")}} interface is a string containing the username component of the `<area>` element's `href`. If the URL does not have a username, this property contains an empty string, `""`.

This property can be set to change the username of the URL. If the URL has no {{domxref("HTMLAreaElement.host", "host")}} or its scheme is `file:`, then setting this property has no effect.

The username is {{Glossary("Percent-encoding", "percent-encoded")}} when setting but not percent-decoded when reading.

See {{domxref("URL.username")}} for more information.

## Value

Expand Down
4 changes: 2 additions & 2 deletions files/en-us/web/api/location/hash/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ browser-compat: api.Location.hash

{{ APIRef("Location") }}

The **`hash`** property of the {{domxref("Location")}} interface returns a string containing a `'#'` followed by the fragment identifier of the URL the ID on the page that the URL is trying to target.
The **`hash`** property of the {{domxref("Location")}} interface is a string containing a `"#"` followed by the fragment identifier of the location URL. If the URL does not have a fragment identifier, this property contains an empty string, `""`.

The fragment is not {{Glossary("Percent-encoding", "percent-encoded")}}. If the URL does not have a fragment identifier, this property contains an empty string, `""`.
See {{domxref("URL.hash")}} for more information.

## Value

Expand Down
7 changes: 3 additions & 4 deletions files/en-us/web/api/location/host/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ browser-compat: api.Location.host

{{ApiRef("Location")}}

The **`host`** property of the {{domxref("Location")}}
interface is a string containing the host, that is the
_hostname_, and then, if the _port_ of the URL is nonempty, a
`':'`, and the _port_ of the URL.
The **`host`** property of the {{domxref("Location")}} interface is a string containing the host, which is the {{domxref("Location.hostname", "hostname")}}, and then, if the {{glossary("port")}} of the URL is nonempty, a `":"`, followed by the {{domxref("Location.port", "port")}} of the URL. If the URL does not have a `hostname`, this property contains an empty string, `""`.

See {{domxref("URL.host")}} for more information.

## Value

Expand Down
Loading