AK: Don't try to complete relative data: URLs

This commit is contained in:
Andreas Kling 2020-06-07 18:23:33 +02:00
parent ab4c03ce2d
commit ec83555b87
Notes: sideshowbarker 2024-07-19 05:46:57 +09:00

View file

@ -47,6 +47,9 @@ static inline bool is_digit(char ch)
bool URL::parse(const StringView& string)
{
if (string.is_null())
return false;
enum class State {
InProtocol,
InHostname,
@ -291,10 +294,16 @@ String URL::to_string() const
URL URL::complete_url(const String& string) const
{
if (!is_valid())
return {};
URL url(string);
if (url.is_valid())
return url;
if (protocol() == "data")
return {};
if (string.starts_with("//")) {
URL url(String::format("%s:%s", m_protocol.characters(), string.characters()));
if (url.is_valid())