Edit this page

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

This feature is experimental. It may be changed or removed in a future version.

Returns whether the given URL matches the current browser location.


location.hostname // => '/path'

up.history.isLocation('/path') // => true
up.history.isLocation('/path?query') // => false
up.history.isLocation('/path#hash') // => false
up.history.isLocation('/other') // => false

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

location.hostname // => '/current-host'
location.pathname // => '/foo'

up.history.isLocation('/foo') // => true
up.history.isLocation('http://current-host/foo') // => true
up.history.isLocation('http://otgher-host/foo') // => false


url string

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://...).

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

Return value