summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-09-28 02:11:55 +0300
committerAndreas Kling <kling@serenityos.org>2021-09-28 16:51:27 +0200
commit01417c82c585162ec516736213245a347c4a3c01 (patch)
treed666dbf2c9904038b9544156465c807b5f4d147c /Userland/Libraries/LibWeb/URL/URLSearchParams.cpp
parent14e99b9b68da7de3bf4c4e5f8c932de99e8572c8 (diff)
downloadserenity-01417c82c585162ec516736213245a347c4a3c01.zip
LibWeb: Make URLSearchParams iterable
This uses the new support for the iterable IDL property.
Diffstat (limited to 'Userland/Libraries/LibWeb/URL/URLSearchParams.cpp')
-rw-r--r--Userland/Libraries/LibWeb/URL/URLSearchParams.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp
index 3ff4368c89..82a556c09d 100644
--- a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp
+++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp
@@ -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;
+ }
+}
+
}