Skip to content

Function: sanitizePathname()

API / @xmachines/play-url / index / sanitizePathname

function sanitizePathname(pathname): string | null;

Defined in: packages/play-url/src/location.ts:89

Reads the pathname of a location, and refuses a location that no route can match.

The function removes the query and the fragment, and it joins every run of separators into one: //docs//api gives /docs/api. A route map holds one pattern for one path, and a doubled separator is the same path written another way.

Parameters

ParameterTypeDescription
pathnamestringThe raw value that a framework router reports.

Returns

string | null

The clean pathname, or null when the value is longer than 2048 characters.