diff options
author | Luke Wilde <lukew@serenityos.org> | 2021-10-26 22:06:55 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-26 23:11:57 +0200 |
commit | fb321bad350d972b9b1cf4c27d3c3456a7466776 (patch) | |
tree | a8ccf82f577ae927b32d2213017079dc47b3b502 /Userland/Libraries/LibWeb/URL/URLSearchParams.cpp | |
parent | 09d1db5afd489ef83c17e4e1a9f02b7bbf17cd07 (diff) | |
download | serenity-fb321bad350d972b9b1cf4c27d3c3456a7466776.zip |
LibWeb: Implement URLSearchParams.getAll
Diffstat (limited to 'Userland/Libraries/LibWeb/URL/URLSearchParams.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/URL/URLSearchParams.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp index 82a556c09d..8785fc8f71 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp @@ -131,6 +131,18 @@ String URLSearchParams::get(String const& name) return result->value; } +// https://url.spec.whatwg.org/#dom-urlsearchparams-getall +Vector<String> URLSearchParams::get_all(String const& name) +{ + // return the values of all name-value pairs whose name is name, in this’s list, in list order, and the empty sequence otherwise. + Vector<String> values; + for (auto& entry : m_list) { + if (entry.name == name) + values.append(entry.value); + } + return values; +} + bool URLSearchParams::has(String const& name) { // return true if there is a name-value pair whose name is name in this’s list, and false otherwise. |