1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 06:28:13 +00:00

LibWeb: Make URLSearchParams iterable

This uses the new support for the iterable IDL property.
This commit is contained in:
Idan Horowitz 2021-09-28 02:11:55 +03:00 committed by Andreas Kling
parent 14e99b9b68
commit 01417c82c5
7 changed files with 101 additions and 2 deletions

View file

@ -195,4 +195,13 @@ String URLSearchParams::to_string()
return url_encode(m_list, AK::URL::PercentEncodeSet::ApplicationXWWWFormUrlencoded);
}
void URLSearchParams::for_each(Function<IterationDecision(String const&, String const&)> callback)
{
for (auto i = 0u; i < m_list.size(); ++i) {
auto& query_param = m_list[i]; // We are explicitly iterating over the indices here as the callback might delete items from the list
if (callback(query_param.name, query_param.value) == IterationDecision::Break)
break;
}
}
}