mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:18:13 +00:00
AK+Tests+LibWeb: Make URL::complete_url()
take a StringView
All it does is pass this to `URLParser::parse()` which takes a StringView, so we might as well take one here too.
This commit is contained in:
parent
8af65108e4
commit
abc01cc9fe
5 changed files with 7 additions and 7 deletions
|
@ -39,12 +39,12 @@ DeprecatedString URL::path() const
|
||||||
return builder.to_deprecated_string();
|
return builder.to_deprecated_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
URL URL::complete_url(DeprecatedString const& string) const
|
URL URL::complete_url(StringView relative_url) const
|
||||||
{
|
{
|
||||||
if (!is_valid())
|
if (!is_valid())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
return URLParser::parse(string, this);
|
return URLParser::parse(relative_url, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void URL::set_scheme(DeprecatedString scheme)
|
void URL::set_scheme(DeprecatedString scheme)
|
||||||
|
|
2
AK/URL.h
2
AK/URL.h
|
@ -88,7 +88,7 @@ public:
|
||||||
|
|
||||||
bool equals(URL const& other, ExcludeFragment = ExcludeFragment::No) const;
|
bool equals(URL const& other, ExcludeFragment = ExcludeFragment::No) const;
|
||||||
|
|
||||||
URL complete_url(DeprecatedString const&) const;
|
URL complete_url(StringView) const;
|
||||||
|
|
||||||
bool data_payload_is_base64() const { return m_data_payload_is_base64; }
|
bool data_payload_is_base64() const { return m_data_payload_is_base64; }
|
||||||
DeprecatedString const& data_mime_type() const { return m_data_mime_type; }
|
DeprecatedString const& data_mime_type() const { return m_data_mime_type; }
|
||||||
|
|
|
@ -403,7 +403,7 @@ TEST_CASE(complete_file_url_with_base)
|
||||||
EXPECT_EQ(url.paths()[0], "home");
|
EXPECT_EQ(url.paths()[0], "home");
|
||||||
EXPECT_EQ(url.paths()[1], "index.html");
|
EXPECT_EQ(url.paths()[1], "index.html");
|
||||||
|
|
||||||
auto sub_url = url.complete_url("js/app.js");
|
auto sub_url = url.complete_url("js/app.js"sv);
|
||||||
EXPECT(sub_url.is_valid());
|
EXPECT(sub_url.is_valid());
|
||||||
EXPECT_EQ(sub_url.path(), "/home/js/app.js");
|
EXPECT_EQ(sub_url.path(), "/home/js/app.js");
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,9 +77,9 @@ bool ParsingContext::in_quirks_mode() const
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-values-4/#relative-urls
|
// https://www.w3.org/TR/css-values-4/#relative-urls
|
||||||
AK::URL ParsingContext::complete_url(DeprecatedString const& addr) const
|
AK::URL ParsingContext::complete_url(StringView relative_url) const
|
||||||
{
|
{
|
||||||
return m_url.complete_url(addr);
|
return m_url.complete_url(relative_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
Parser::Parser(ParsingContext const& context, StringView input, StringView encoding)
|
Parser::Parser(ParsingContext const& context, StringView input, StringView encoding)
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
|
|
||||||
bool in_quirks_mode() const;
|
bool in_quirks_mode() const;
|
||||||
DOM::Document const* document() const { return m_document; }
|
DOM::Document const* document() const { return m_document; }
|
||||||
AK::URL complete_url(DeprecatedString const&) const;
|
AK::URL complete_url(StringView) const;
|
||||||
|
|
||||||
PropertyID current_property_id() const { return m_current_property_id; }
|
PropertyID current_property_id() const { return m_current_property_id; }
|
||||||
void set_current_property_id(PropertyID property_id) { m_current_property_id = property_id; }
|
void set_current_property_id(PropertyID property_id) { m_current_property_id = property_id; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue