forked from LadybirdBrowser/ladybird
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Actually set empty serialized query to OptionalNone
Because the type returned by to_string is a String, _not_ an Optional<String>, the following code: if (serialized_query.is_empty()) serialized_query = {}; Was achieving nothing at all! Make sure that the type is an Optional<String> so that we're not just setting an empty string to an empty string.
- Loading branch information
1 parent
1ba6dbd
commit d755a83
Showing
3 changed files
with
15 additions
and
3 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
Tests/LibWeb/Text/expected/URL/search-params-with-no-query.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
https://www.birdoftheyear.org.nz/? | ||
https://www.birdoftheyear.org.nz/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script src="../include.js"></script> | ||
<script> | ||
test(() => { | ||
let url = new URL("https://www.birdoftheyear.org.nz/?") | ||
println(url.href); | ||
url.searchParams.sort() | ||
println(url.href); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Copyright (c) 2021, Idan Horowitz <[email protected]> | ||
* Copyright (c) 2023, Shannon Booth <[email protected]> | ||
* Copyright (c) 2023-2024, Shannon Booth <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
@@ -213,17 +213,18 @@ void URLSearchParams::append(String const& name, String const& value) | |
update(); | ||
} | ||
|
||
// https://url.spec.whatwg.org/#concept-urlsearchparams-update | ||
void URLSearchParams::update() | ||
{ | ||
// 1. If query’s URL object is null, then return. | ||
if (!m_url) | ||
return; | ||
|
||
// 2. Let serializedQuery be the serialization of query’s list. | ||
auto serialized_query = to_string(); | ||
Optional<String> serialized_query = to_string(); | ||
|
||
// 3. If serializedQuery is the empty string, then set serializedQuery to null. | ||
if (serialized_query.is_empty()) | ||
if (serialized_query == String {}) | ||
serialized_query = {}; | ||
|
||
// 4. Set query’s URL object’s URL’s query to serializedQuery. | ||
|