From f1f928670e7e5e61bcf4031fd5bdfd2c132fb23a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 17 Oct 2019 20:21:57 +0200 Subject: [PATCH] URL: Parse URLs that lack a path (e.g "http://serenityos.org") --- AK/URL.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/AK/URL.cpp b/AK/URL.cpp index dc5286e620d..81fda73dd7b 100644 --- a/AK/URL.cpp +++ b/AK/URL.cpp @@ -109,6 +109,14 @@ bool URL::parse(const StringView& string) continue; } } + if (state == State::InHostname) { + // We're still in the hostname, so e.g "http://serenityos.org" + if (buffer.is_empty()) + return false; + m_host = String::copy(buffer); + m_path = "/"; + return true; + } m_path = String::copy(buffer); return true; }