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

Example​

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

Returns​

string | undefined

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


redirectTo()​

redirectTo(url): void

Defined in: location/index.ts:26

Redirects the browser to a new URL.

Example​

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

Parameters​

url​

string

The URL to redirect to.

Returns​

void


reloadPage()​

reloadPage(): void

Defined in: location/index.ts:40

Reloads the current page.

Example​

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

Returns​

void


getPathname()​

getPathname(): string | undefined

Defined in: location/index.ts:55

Gets the current pathname from the browser location.

Example​

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

Returns​

string | undefined

The pathname, or undefined if not in a browser.


getSearch()​

getSearch(): string | undefined

Defined in: location/index.ts:71

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

Example​

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

Returns​

string | undefined

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


getHash()​

getHash(): string | undefined

Defined in: location/index.ts:87

Gets the current hash from the browser location.

Example​

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

Returns​

string | undefined

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