Skip to main content

Function: safeRedirectPath()

safeRedirectPath(requested, origin, fallback?): string

Defined in: src/lib/url.ts:6

Validate a client-supplied redirect target down to a same-origin path. Resolves against the given origin and requires it to stay there — a plain leading-"/" check is not enough, since URL parsing treats "" as "/" for http(s), so "/\evil.com" would escape the origin.

Parameters

requested

unknown

origin

string

fallback?

string = '/login'

Returns

string