Skip to main content

@rtorcato/browser-common / location

location

Functions

getCurrentLocation()

getCurrentLocation(): string | undefined

Defined in: location/index.ts:10

Gets the current browser location (window.location.href).

Returns

string | undefined

The current URL, or undefined if not in a browser.

Example

import { getCurrentLocation } from '@rtorcato/browser-common/location'
const url = getCurrentLocation()

redirectTo()

redirectTo(url): void

Defined in: location/index.ts:26

Redirects the browser to a new URL.

Parameters

url

string

The URL to redirect to.

Returns

void

Example

import { redirectTo } from '@rtorcato/browser-common/location'
redirectTo('/login')

reloadPage()

reloadPage(): void

Defined in: location/index.ts:40

Reloads the current page.

Returns

void

Example

import { reloadPage } from '@rtorcato/browser-common/location'
reloadPage()

getPathname()

getPathname(): string | undefined

Defined in: location/index.ts:55

Gets the current pathname from the browser location.

Returns

string | undefined

The pathname, or undefined if not in a browser.

Example

import { getPathname } from '@rtorcato/browser-common/location'
if (getPathname() === '/home') showHome()

getSearch()

getSearch(): string | undefined

Defined in: location/index.ts:71

Gets the current search (query string) from the browser location.

Returns

string | undefined

The search string, or undefined if not in a browser.

Example

import { getSearch } from '@rtorcato/browser-common/location'
const qs = getSearch()

getHash()

getHash(): string | undefined

Defined in: location/index.ts:87

Gets the current hash from the browser location.

Returns

string | undefined

The hash string, or undefined if not in a browser.

Example

import { getHash } from '@rtorcato/browser-common/location'
const hash = getHash()