diff --git a/Libraries/LibURL/URL.cpp b/Libraries/LibURL/URL.cpp index f36693ae715..4debaa956f4 100644 --- a/Libraries/LibURL/URL.cpp +++ b/Libraries/LibURL/URL.cpp @@ -475,6 +475,16 @@ String percent_encode(StringView input, PercentEncodeSet set, SpaceAsPlus space_ return MUST(builder.to_string()); } +URL URL::about(String path) +{ + URL url; + url.m_data->valid = true; + url.m_data->scheme = "about"_string; + url.m_data->paths = { move(path) }; + url.m_data->cannot_be_a_base_url = true; + return url; +} + // https://url.spec.whatwg.org/#percent-decode ByteString percent_decode(StringView input) { diff --git a/Libraries/LibURL/URL.h b/Libraries/LibURL/URL.h index 86782ebd99b..5d54f6687da 100644 --- a/Libraries/LibURL/URL.h +++ b/Libraries/LibURL/URL.h @@ -147,6 +147,8 @@ public: Optional const& blob_url_entry() const { return m_data->blob_url_entry; } void set_blob_url_entry(Optional entry) { m_data->blob_url_entry = move(entry); } + static URL about(String path); + private: bool compute_validity() const; @@ -211,6 +213,12 @@ URL create_with_data(StringView mime_type, StringView payload, bool is_base64 = bool is_public_suffix(StringView host); Optional get_public_suffix(StringView host); +inline URL about_blank() { return URL::about("blank"_string); } +inline URL about_srcdoc() { return URL::about("srcdoc"_string); } +inline URL about_error() { return URL::about("error"_string); } +inline URL about_version() { return URL::about("version"_string); } +inline URL about_newtab() { return URL::about("newtab"_string); } + } template<>