mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
AK: Use base URL when the specified URL is empty
This commit is contained in:
parent
96d3d3b0fe
commit
401bc13776
Notes:
sideshowbarker
2024-07-17 02:08:15 +09:00
Author: https://github.com/Thihup Commit: https://github.com/SerenityOS/serenity/commit/401bc13776 Pull-request: https://github.com/SerenityOS/serenity/pull/16689 Issue: https://github.com/SerenityOS/serenity/issues/16688 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/kleinesfilmroellchen ✅
2 changed files with 10 additions and 1 deletions
|
@ -201,7 +201,7 @@ URL URLParser::parse(StringView raw_input, URL const* base_url, Optional<URL> ur
|
|||
{
|
||||
dbgln_if(URL_PARSER_DEBUG, "URLParser::parse: Parsing '{}'", raw_input);
|
||||
if (raw_input.is_empty())
|
||||
return {};
|
||||
return base_url ? *base_url : URL {};
|
||||
|
||||
if (raw_input.starts_with("data:"sv)) {
|
||||
auto maybe_url = parse_data_url(raw_input);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <AK/Base64.h>
|
||||
#include <AK/URL.h>
|
||||
#include <AK/URLParser.h>
|
||||
|
||||
TEST_CASE(construct)
|
||||
{
|
||||
|
@ -406,3 +407,11 @@ TEST_CASE(complete_file_url_with_base)
|
|||
EXPECT(sub_url.is_valid());
|
||||
EXPECT_EQ(sub_url.path(), "/home/js/app.js");
|
||||
}
|
||||
|
||||
TEST_CASE(empty_url_with_base_url)
|
||||
{
|
||||
URL base_url { "https://foo.com/"sv };
|
||||
URL parsed_url = URLParser::parse(""sv, &base_url);
|
||||
EXPECT_EQ(parsed_url.is_valid(), true);
|
||||
EXPECT(base_url.equals(parsed_url));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue