[webkit-changes] [WebKit/WebKit] e9fd9c: WTF::removeQueryParameters should not reencode and...
Wenson Hsieh
noreply at github.com
Thu Oct 27 15:02:46 PDT 2022
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e9fd9cc2e7f15f9c93c833bfcb443d28da33276e
https://github.com/WebKit/WebKit/commit/e9fd9cc2e7f15f9c93c833bfcb443d28da33276e
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2022-10-27 (Thu, 27 Oct 2022)
Changed paths:
M Source/WTF/wtf/URL.cpp
M Source/WTF/wtf/URLParser.cpp
M Source/WTF/wtf/URLParser.h
M Tools/TestWebKitAPI/Tests/WTF/URL.cpp
Log Message:
-----------
WTF::removeQueryParameters should not reencode and reparse the query string if nothing was removed
https://bugs.webkit.org/show_bug.cgi?id=247131
Reviewed by Chris Dumez.
Add a minor optimization to the `WTF::removeQueryParameters` helper function. In the case where no
query parameters were removed, we should leave that part of the query string alone, instead of
forcing both the key and value to become percent-encoded. Additionally, in the case where no query
parameters were removed altogether, we can skip setting (and re-parsing) the query string
altogether, and instead simply return without modifying the given URL.
* Source/WTF/wtf/URL.cpp:
(WTF::removeQueryParameters):
* Source/WTF/wtf/URLParser.cpp:
(WTF::URLParser::parseURLEncodedForm):
(WTF::URLParser::parseQueryNameAndValue):
* Source/WTF/wtf/URLParser.h:
* Tools/TestWebKitAPI/Tests/WTF/URL.cpp:
Augment an existing API test to exercise this change.
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/256078@main
More information about the webkit-changes
mailing list