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

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).
This commit is contained in:
MacDue 2023-04-13 23:29:51 +01:00 committed by Andreas Kling
parent 35612c6a7f
commit 5db1eb9961
6 changed files with 28 additions and 21 deletions

View file

@ -65,6 +65,8 @@ public:
DeprecatedString query(ApplyPercentDecoding = ApplyPercentDecoding::No) const;
DeprecatedString fragment(ApplyPercentDecoding = ApplyPercentDecoding::Yes) const;
Optional<u16> port() const { return m_port; }
DeprecatedString path_segment_at_index(size_t index, ApplyPercentDecoding = ApplyPercentDecoding::Yes) const;
size_t path_segment_count() const { return m_paths.size(); }
u16 port_or_default() const { return m_port.value_or(default_port_for_scheme(m_scheme)); }
bool cannot_be_a_base_url() const { return m_cannot_be_a_base_url; }