Skip to main content

url-decode

$url-decode

Decodes a percent-encoded URL string.

Use {$url-decode: {full: true}} to decode a complete URL (decodeURI) rather than a component (decodeURIComponent). Full-URL decoding preserves sequences that are valid structural URL characters (%2F etc.) undecoded.

Throws if the input is not a string or contains a malformed escape sequence.

Parameters

  • full (boolean, optional, default false): Use full-URL decoding (decodeURI) rather than component decoding (decodeURIComponent).

Example

// Decode a percent-encoded query parameter
new Schema('string').normalizer('$url-decode')
// 'hello%20world%20%26%20more' → 'hello world & more'

// Decode a full URL without decoding structural characters
new Schema('string').normalizer({'$url-decode': {full: true}})
// 'https://example.com/path%20with%20spaces' → 'https://example.com/path with spaces'

// Decode then validate the result
new Schema('string').normalizer('$url-decode').validator('$non-empty')