# Class URL

- [TopLevel.Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)
  - [dw.web.URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md)

Represents a URL in Commerce Cloud Digital.

## Constructor Summary

This class does not have a constructor, so you cannot create it directly.

## Method Summary

| Method                                                                                                                                                                                                                                                                    | Description                                                                                                                         |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| [abs](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md#abs)()                                                                                                                                                                                          | Makes the URL absolute and ensures that the protocol of the request is used  or http in a mail context.                             |
| [append](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md#appendstring-string)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)) | Append a request parameter to this URL.                                                                                             |
| [appendCSRFTokenBM](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md#appendcsrftokenbm)()                                                                                                                                                              | <p>Appends, if applicable, a CSRF protection token to this URL.                                                                     |
| [host](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md#hoststring)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))                                                                                                | Updates the URL with the specified host name  Note: This method is not applicable for static content or image transformation  URLs. |
| [http](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md#http)()                                                                                                                                                                                        | Makes the URL absolute and ensures that the protocol http is used.                                                                  |
| [https](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md#https)()                                                                                                                                                                                      | Makes the URL absolute and ensures that the protocol https is used.                                                                 |
| [relative](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md#relative)()                                                                                                                                                                                | Makes the URL relative.                                                                                                             |
| [remove](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md#removestring)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))                                                                                            | Remove a request parameter from this URL.                                                                                           |
| [siteHost](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md#sitehost)()                                                                                                                                                                                | Updates the URL with the site host name  Note: This method is not applicable for static content or image transformation  URLs.      |
| [toString](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md#tostring)()                                                                                                                                                                                | Return String representation of the URL.                                                                                            |

### Methods inherited from class Object

[assign](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#assignobject-object), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject-object), [defineProperties](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertiesobject-object), [defineProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertyobject-object-object), [entries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#entriesobject), [freeze](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#freezeobject), [fromEntries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#fromentriesiterable), [getOwnPropertyDescriptor](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertydescriptorobject-object), [getOwnPropertyNames](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertynamesobject), [getOwnPropertySymbols](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertysymbolsobject), [getPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getprototypeofobject), [hasOwnProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#hasownpropertystring), [is](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isobject-object), [isExtensible](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isextensibleobject), [isFrozen](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isfrozenobject), [isPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isprototypeofobject), [isSealed](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#issealedobject), [keys](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#keysobject), [preventExtensions](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#preventextensionsobject), [propertyIsEnumerable](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#propertyisenumerablestring), [seal](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#sealobject), [setPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#setprototypeofobject-object), [toLocaleString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tolocalestring), [toString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tostring), [valueOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valueof), [values](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valuesobject)

## Method Details

### abs()

- abs(): [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md)
  - : Makes the URL absolute and ensures that the protocol of the request is used
    or http in a mail context.
    Note: This method is not applicable for static content or image transformation
    URLs. In this case a runtime exception is thrown.

    **Returns:**

    - A new URL instance.

***

### append(String, String)

- append(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md), value: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)): [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md)
  - : Append a request parameter to this URL.

    **Parameters:**

    - name - The parameter name.  Must not be null.
    - value - The parameter value.  If null, then treated as empty value.

    **Returns:**

    - A reference to this URL.

***

### appendCSRFTokenBM()

- appendCSRFTokenBM(): [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md)
  - :
    Appends, if applicable, a CSRF protection token to this URL. The CSRF token will only be appended under the following conditions:

    - the URL is a pipeline URL

    - the URL is for Business Manager

    If a CSRF token already exists in the URL, it will be replaced with a newly generated one.

    **Returns:**

    - a reference to this URL, with a CSRF token appended if applicable.

***

### host(String)

- host(host: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)): [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md)
  - : Updates the URL with the specified host name
    Note: This method is not applicable for static content or image transformation
    URLs. In this case a runtime exception is thrown.

    **Parameters:**

    - host - The host name that is used to update the URL.

    **Returns:**

    - A new URL instance.

***

### http()

- http(): [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md)
  - : Makes the URL absolute and ensures that the protocol http is used.
    Note: This method is not applicable for static content or image transformation
    URLs. In this case a runtime exception is thrown.

    **Returns:**

    - A new URL instance.

***

### https()

- https(): [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md)
  - : Makes the URL absolute and ensures that the protocol https is used.
    Note: This method is not applicable for static content or image transformation
    URLs. In this case a runtime exception is thrown.

    **Returns:**

    - A new URL instance.

***

### relative()

- relative(): [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md)
  - : Makes the URL relative.
    Note: This method is not applicable for static content or image transformation
    URLs. In this case a runtime exception is thrown.

    **Returns:**

    - A new URL instance.

***

### remove(String)

- remove(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)): [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md)
  - : Remove a request parameter from this URL. If the parameter is not part
    of the URL, nothing is done.

    **Parameters:**

    - name - The parameter name.  Must not be null.

    **Returns:**

    - A reference to this URL.

***

### siteHost()

- siteHost(): [URL](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.web.URL.md)
  - : Updates the URL with the site host name
    Note: This method is not applicable for static content or image transformation
    URLs. In this case a runtime exception is thrown.

    **Returns:**

    - A new URL instance.

***

### toString()

- toString(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Return String representation of the URL.

    **Returns:**

    - the URL as a string.

***
