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

# up.history.isLocation(url, [options])

Returns whether the given URL matches the [current browser location](https://unpoly.com/api/up.history.location.md).

<nav aria-label="Contents">

#### Contents

- [Examples](#examples)
- [Parameters](#parameters)
- [Return value](#return-value)

</nav>

## Examples {#examples}

```js
location.pathname // => '/path'

up.history.isLocation('/path') // result: true
up.history.isLocation('/other') // result: false
```

By default, a trailing `#hash` and a `?query` string are considered for the comparison. To ignore the `#hash`, pass `{ hash: false }`:

```js
location.pathname // => '/path'

up.history.isLocation('/path#hash') // result: false
up.history.isLocation('/path#hash', { hash: false }) // result: true
up.history.isLocation('/path?query') // result: false
```

The given URL is [normalized](https://unpoly.com/api/up.util.normalizeURL.md), so any URL string pointing to the browser location will match:

```js
location.hostname // result: 'current-host'
location.pathname // => '/foo'

up.history.isLocation('/foo') // result: true
up.history.isLocation('http://current-host/foo') // result: true
up.history.isLocation('http://other-host/foo') // result: false
```

---

## Parameters {#parameters}

### url {#url}

(required)

The URL to compare against the current browser location.

This can be either an absolute pathname (`/path`), a relative filename (`index.html`), or a fully qualified URL (`https://...`).

Type: string

### [options.hash=true] {#options.hash}

(optional)

Whether to consider `#hash` fragments in the given or current URLs.

When set to `false`, this function will consider the URLs `/foo#one` and `/foo#two` to be equal.

Type: boolean

---

## Return value {#return-value}

Whether the browser is currently at the given location.

Type: boolean

