summaryrefslogtreecommitdiff
path: root/AK/URL.cpp
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2023-04-13 23:29:51 +0100
committerAndreas Kling <kling@serenityos.org>2023-04-15 06:37:04 +0200
commit5db1eb996173b34960f48c7ea8ce4fd33acde157 (patch)
tree3821497e14788bebd9a675ca44d73d574cb3f420 /AK/URL.cpp
parent35612c6a7f7602ff46d56bbbbc8b33b28b411409 (diff)
downloadserenity-5db1eb996173b34960f48c7ea8ce4fd33acde157.zip
AK+Everywhere: Replace URL::paths() with path_segment_at_index()
This allows accessing and looping over the path segments in a URL without necessarily allocating a new vector if you want them percent decoded too (which path_segment_at_index() has an option for).
Diffstat (limited to 'AK/URL.cpp')
-rw-r--r--AK/URL.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/AK/URL.cpp b/AK/URL.cpp
index 0aa17f6c52..c50aa6a5d0 100644
--- a/AK/URL.cpp
+++ b/AK/URL.cpp
@@ -45,6 +45,12 @@ DeprecatedString URL::password(ApplyPercentDecoding apply_percent_decoding) cons
return apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(m_password) : m_password;
}
+DeprecatedString URL::path_segment_at_index(size_t index, ApplyPercentDecoding apply_percent_decoding) const
+{
+ VERIFY(index < path_segment_count());
+ return apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(m_paths[index]) : m_paths[index];
+}
+
DeprecatedString URL::basename(ApplyPercentDecoding apply_percent_decoding) const
{
if (!m_valid)