Skip to main content

escape_leading_slashes

If redirecting to an absolute path (two leading slashes), a slash must be escaped to prevent browsers from handling the path as schemaless and redirecting to another host.

def escape_leading_slashes(
url: string
) - > string

If redirecting to an absolute path (two leading slashes), a slash must be escaped to prevent browsers from handling the path as schemaless and redirecting to another host.

Parameters

NameTypeDescription
urlstringThe URL string to be checked and potentially escaped to prevent open redirect vulnerabilities.

Returns

TypeDescription
stringThe URL with leading double slashes replaced by an escaped sequence, or the original URL if it did not start with double slashes.