diff --git a/Tests/LibWeb/Text/expected/URL/search-params-strip-trailing-spaces-from-opaque-url.txt b/Tests/LibWeb/Text/expected/URL/search-params-strip-trailing-spaces-from-opaque-url.txt new file mode 100644 index 00000000000..8b09e1ec3a7 --- /dev/null +++ b/Tests/LibWeb/Text/expected/URL/search-params-strip-trailing-spaces-from-opaque-url.txt @@ -0,0 +1,6 @@ +URL pathname is 'space ' +URL href is 'data:space ?test' +true +false +URL pathname is 'space' +URL href is 'data:space' diff --git a/Tests/LibWeb/Text/input/URL/search-params-strip-trailing-spaces-from-opaque-url.html b/Tests/LibWeb/Text/input/URL/search-params-strip-trailing-spaces-from-opaque-url.html new file mode 100644 index 00000000000..02f7a470a89 --- /dev/null +++ b/Tests/LibWeb/Text/input/URL/search-params-strip-trailing-spaces-from-opaque-url.html @@ -0,0 +1,16 @@ + + diff --git a/Userland/Libraries/LibWeb/DOMURL/URLSearchParams.cpp b/Userland/Libraries/LibWeb/DOMURL/URLSearchParams.cpp index 2a3863eb395..5a386928d0f 100644 --- a/Userland/Libraries/LibWeb/DOMURL/URLSearchParams.cpp +++ b/Userland/Libraries/LibWeb/DOMURL/URLSearchParams.cpp @@ -229,6 +229,10 @@ void URLSearchParams::update() // 4. Set query’s URL object’s URL’s query to serializedQuery. m_url->set_query({}, move(serialized_query)); + + // 5. If serializedQuery is null, then potentially strip trailing spaces from an opaque path with query’s URL object. + if (!serialized_query.has_value()) + strip_trailing_spaces_from_an_opaque_path(*m_url); } // https://url.spec.whatwg.org/#dom-urlsearchparams-delete