AK: Add URL::raw_fragment()

This is a little hackish. Part of the algorithm to get the indicated
part of a DOM::Document
https://html.spec.whatwg.org/multipage/browsing-the-web.html#the-indicated-part-of-the-document
wants to first get the URL's fragment, use it, and then later
percent-decode it and use that. So, we need a way to get that
un-decoded fragment.
This commit is contained in:
Sam Atkins 2023-08-09 17:23:23 +01:00 committed by Andreas Kling
parent c0cf6e3744
commit 28aa4ca767
Notes: sideshowbarker 2024-07-17 01:12:07 +09:00
2 changed files with 7 additions and 0 deletions

View File

@ -72,6 +72,11 @@ DeprecatedString URL::fragment() const
return percent_decode(m_fragment);
}
DeprecatedString URL::raw_fragment() const
{
return m_fragment;
}
// NOTE: This only exists for compatibility with the existing URL tests which check for both .is_null() and .is_empty().
static DeprecatedString deprecated_string_percent_encode(DeprecatedString const& input, URL::PercentEncodeSet set = URL::PercentEncodeSet::Userinfo, URL::SpaceAsPlus space_as_plus = URL::SpaceAsPlus::No)
{

View File

@ -83,7 +83,9 @@ public:
ErrorOr<String> serialized_host() const;
DeprecatedString basename() const;
DeprecatedString query() const;
// NOTE: fragment() is percent-decoded, raw_fragment() is not.
DeprecatedString fragment() const;
DeprecatedString raw_fragment() const;
Optional<u16> port() const { return m_port; }
DeprecatedString path_segment_at_index(size_t index) const;
size_t path_segment_count() const { return m_paths.size(); }