1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:17:35 +00:00

LibWeb: Implement URLSearchParams.getAll

This commit is contained in:
Luke Wilde 2021-10-26 22:06:55 +01:00 committed by Linus Groh
parent 09d1db5afd
commit fb321bad35
3 changed files with 14 additions and 1 deletions

View file

@ -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 thiss 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 thiss list, and false otherwise.

View file

@ -35,6 +35,7 @@ public:
void append(String const& name, String const& value);
void delete_(String const& name);
String get(String const& name);
Vector<String> get_all(String const& name);
bool has(String const& name);
void set(String const& name, String const& value);

View file

@ -6,7 +6,7 @@ interface URLSearchParams {
undefined append(USVString name, USVString value);
undefined delete(USVString name);
USVString? get(USVString name);
// TODO: sequence<USVString> getAll(USVString name);
sequence<USVString> getAll(USVString name);
boolean has(USVString name);
undefined set(USVString name, USVString value);