Skip to content

Interface: URLAttributes ​

The attributes of a URL, given to the URLBuilder constructor to build one; all are optional.

Properties ​

auth? ​

optional auth?: string

The credentials, username:password or username: they set username and password.


hash? ​

optional hash?: string

The fragment, # added when missing.


host? ​

optional host?: string

The host name with its port ('example.com:8080'): it sets hostname and port, which win over it when given too.


hostname? ​

optional hostname?: string

The host name, without port.


href? ​

optional href?: string

Kept as given, not used to build: the URL is made of the other attributes.


origin? ​

optional origin?: string

Kept as given, not used to build: it is the protocol and the host.


password? ​

optional password?: string

The password of the credentials, percent-encoded when built.


pathname? ​

optional pathname?: string

The path, / added when missing.


port? ​

optional port?: string

The port; not written when it is the scheme's default (443 for https, 80 for http).


protocol? ​

optional protocol?: string

The scheme, with or without its colon ('https', 'redis:'). Any scheme is accepted.


query? ​

optional query?: Record<string, string>

The query parameters by name, percent-encoded when built ({q: 'a b'} gives ?q=a%20b); an empty object gives no query.


slashes? ​

optional slashes?: boolean

Whether the protocol is followed by // (always for http, https, ws, wss, ftp, file and gopher).

Default ​

ts
true with a protocol

username? ​

optional username?: string

The user name of the credentials, percent-encoded when built.

Released under the MIT License.