mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:17:35 +00:00
AK: Add spec-compliant URL serialization methods
This adds URL serialization methods which are more in line with the specification. The serialize_for_display() method should be used e.g. in the browser address bar, and as per the spec should not display username and password. Furthermore, it could decode most percent-encoded code points, although that is not implemented yet.
This commit is contained in:
parent
0d0ed4962f
commit
1697f3c35b
2 changed files with 131 additions and 0 deletions
9
AK/URL.h
9
AK/URL.h
|
@ -30,6 +30,11 @@ public:
|
|||
EncodeURI
|
||||
};
|
||||
|
||||
enum class ExcludeFragment {
|
||||
No,
|
||||
Yes
|
||||
};
|
||||
|
||||
URL() = default;
|
||||
URL(const StringView&);
|
||||
URL(const char* string)
|
||||
|
@ -78,6 +83,9 @@ public:
|
|||
return percent_encode(to_string(), PercentEncodeSet::EncodeURI);
|
||||
}
|
||||
|
||||
String serialize(ExcludeFragment = ExcludeFragment::No) const;
|
||||
String serialize_for_display() const;
|
||||
|
||||
URL complete_url(const String&) const;
|
||||
|
||||
bool data_payload_is_base64() const { return m_data_payload_is_base64; }
|
||||
|
@ -115,6 +123,7 @@ private:
|
|||
|
||||
bool parse(const StringView&);
|
||||
bool compute_validity() const;
|
||||
String serialize_data_url() const;
|
||||
|
||||
static void append_percent_encoded_if_necessary(StringBuilder&, u32 code_point, PercentEncodeSet set = PercentEncodeSet::Userinfo);
|
||||
static void append_percent_encoded(StringBuilder&, u32 code_point);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue