eslint-plugin-xss icon indicating copy to clipboard operation
eslint-plugin-xss copied to clipboard

Allow URL: toString() on window.location.href

Open gerarts opened this issue 1 year ago • 0 comments

Allow the use of

window.location.href = url.toString();

when url is an instance of URL as encoding is already handled.

See URL Standard > 6.1 URL class

See URL Standard > 6.2 URLSearchParams class

// URL with UTF-8 in path
const url = new URL('/path/шеллы', 'https://example.com');

console.log(url.toString());
// Output: "https://example.com/path/%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"
const url = new URL('/', 'https://example.com');

// Add param with UTF-8 content
url.searchParams.set('some', 'шеллы');

console.log(url.toString());
// Output: "https://example.com/?some=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"

gerarts avatar May 09 '23 09:05 gerarts