---
name: "up.util.parseURL"
area: "API"
kind: "JavaScript function"
parent: "up.util module"
url: "https://unpoly.com/api/up.util.parseURL"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.util module](https://unpoly.com/api/up.util.md)</nav>

# up.util.parseURL(the)

Parses the given URL into components such as hostname and path.

If the given URL is not fully qualified, it is assumed to be relative to the current page.

<nav aria-label="Contents">

#### Contents

- [Example](#example)
- [Parameters](#parameters)
- [Return value](#return-value)

</nav>

## Example {#example}

```js
let parsed = up.util.parseURL('/path?foo=value')
parsed.pathname // result: '/path'
parsed.search // result: '?foo=value'
parsed.hash // result: ''
```

---

## Parameters {#parameters}

### the {#the}

(required)

URL to parse

Type: string | [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL)

---

## Return value {#return-value}

The parsed URL as an object with `{ protocol, hostname, port, pathname, search, hash }` properties.

Type: [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects)

