[@fastly/as-url](../README.md) / URL

# Class: URL

## Table of contents

### Constructors

- [constructor](url.md#constructor)

### Properties

- [\_urlProps](url.md#_urlprops)

### Accessors

- [hash](url.md#hash)
- [host](url.md#host)
- [hostname](url.md#hostname)
- [href](url.md#href)
- [origin](url.md#origin)
- [password](url.md#password)
- [pathname](url.md#pathname)
- [port](url.md#port)
- [protocol](url.md#protocol)
- [search](url.md#search)
- [username](url.md#username)

### Methods

- [toJSON](url.md#tojson)
- [toString](url.md#tostring)

## Constructors

### constructor

\+ **new URL**(`url`: *string*, `baseUrl?`: ``null`` \| *string*): [*URL*](url.md)

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `url` | *string* | - |
| `baseUrl` | ``null`` \| *string* | null |

**Returns:** [*URL*](url.md)

## Properties

### \_urlProps

• `Private` **\_urlProps**: *URLProperties*

## Accessors

### hash

• get **hash**(): *string*

**Returns:** *string*

• set **hash**(`hash`: *string*): *void*

#### Parameters

| Name | Type |
| :------ | :------ |
| `hash` | *string* |

**Returns:** *void*

___

### host

• get **host**(): *string*

**Returns:** *string*

• set **host**(`host`: *string*): *void*

#### Parameters

| Name | Type |
| :------ | :------ |
| `host` | *string* |

**Returns:** *void*

___

### hostname

• get **hostname**(): *string*

**Returns:** *string*

• set **hostname**(`hostname`: *string*): *void*

#### Parameters

| Name | Type |
| :------ | :------ |
| `hostname` | *string* |

**Returns:** *void*

___

### href

• get **href**(): *string*

**Returns:** *string*

• set **href**(`absoluteUrl`: *string*): *void*

#### Parameters

| Name | Type |
| :------ | :------ |
| `absoluteUrl` | *string* |

**Returns:** *void*

___

### origin

• get **origin**(): *string*

**Returns:** *string*

___

### password

• get **password**(): *string*

**Returns:** *string*

• set **password**(`password`: *string*): *void*

#### Parameters

| Name | Type |
| :------ | :------ |
| `password` | *string* |

**Returns:** *void*

___

### pathname

• get **pathname**(): *string*

**Returns:** *string*

• set **pathname**(`pathname`: *string*): *void*

#### Parameters

| Name | Type |
| :------ | :------ |
| `pathname` | *string* |

**Returns:** *void*

___

### port

• get **port**(): *string*

**Returns:** *string*

• set **port**(`port`: *string*): *void*

#### Parameters

| Name | Type |
| :------ | :------ |
| `port` | *string* |

**Returns:** *void*

___

### protocol

• get **protocol**(): *string*

**Returns:** *string*

• set **protocol**(`protocol`: *string*): *void*

#### Parameters

| Name | Type |
| :------ | :------ |
| `protocol` | *string* |

**Returns:** *void*

___

### search

• get **search**(): *string*

**Returns:** *string*

• set **search**(`search`: *string*): *void*

#### Parameters

| Name | Type |
| :------ | :------ |
| `search` | *string* |

**Returns:** *void*

___

### username

• get **username**(): *string*

**Returns:** *string*

• set **username**(`username`: *string*): *void*

#### Parameters

| Name | Type |
| :------ | :------ |
| `username` | *string* |

**Returns:** *void*

## Methods

### toJSON

▸ **toJSON**(): *string*

**Returns:** *string*

___

### toString

▸ **toString**(): *string*

**Returns:** *string*
