mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-30 05:08:56 +00:00
LibURL: Add 'about:XXX' helper factory functions
Currently we create URLs such as 'about:blank' through the StringView or ByteString constructor of URL. However, in order to elimate the use of URL::is_valid, we need to get rid of these constructors as it makes it way too easy to create an invalid URL. It is very cumbersome to construct an 'about:blank' URL when using URL::Parser::basic_parse. So instead of doing that, create some helper functions which will create the 'about:XXX' URLs with the correct properties set. Conveniently, this is also a much faster way of creating these URLs as it means we do not need to parse the URL and can set all of the members up front.
This commit is contained in:
committed by
Tim Ledbetter
parent
53826995f6
commit
07f054e067
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user