servo / rust-url

URL parser for Rust
https://docs.rs/url/
Apache License 2.0
1.27k stars 318 forks source link

URL pathname and search setter incorrectly strips trailing spaces #847

Closed lucacasonato closed 1 year ago

lucacasonato commented 1 year ago

Test case:

const url = new URL('http://example.com/');
url.pathname = '/ ';
url.search = '? ';
url.hash = '# ';
console.log(url.href);

Implementations:

// whatwg-url@13.0.0
"http://example.com/%20?%20#%20" ✅

// Chrome 117.0.5881.0
"http://example.com/%20?%20#%20" ✅

// Firefox 114.0.2
"http://example.com/%20?%20#%20" ✅

// Safari TP 171
"http://example.com/?#%20" ❌

// Deno 1.35.0 (rust-url 2.4.0)
"http://example.com/?%20#%20" ❌

// [node@20.4.0](mailto:node@20.4.0)
"http://example.com/%20?%20#%20" ✅

New tests in https://github.com/web-platform-tests/wpt/pull/40959