Edit this page

up.history up.history.isLocation(url, [options])
JavaScript function

Returns whether the given URL matches the current browser location.

Examples

location.hostname // => '/path'

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

By default, a trailing #hash will be ignored for the comparison. A ?query string will not:

location.hostname // => '/path'

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

The given URL is normalized, so any URL string pointing to the browser location will match:

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://otgher-host/foo') // result: false

Parameters

url
required

The URL to compare against the current browser location.

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

string
[options.hash=true]
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.

boolean

Return value

Whether the browser is currently at the given location.

boolean