mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb: Use correct URL parsing methods throughout LibWeb
There are essentially 3 URL parsing AOs defined by the spec: 1. Parse a URL 2. Encoding parse a URL 3. Encoding parse a URL and serialize the result Further, these are replicated between the Document and the ESO. This patch defines these methods in accordance with the spec and updates existing users to invoke the correct method. In places where the correct method is ambiguous, we use the encoding parser to preserve existing ad- hoc behavior.
This commit is contained in:
@@ -78,14 +78,14 @@ void HTMLLinkElement::inserted()
|
||||
if (m_relationship & Relationship::Preload) {
|
||||
// FIXME: Respect the "as" attribute.
|
||||
LoadRequest request;
|
||||
request.set_url(document().parse_url(get_attribute_value(HTML::AttributeNames::href)));
|
||||
request.set_url(document().encoding_parse_url(get_attribute_value(HTML::AttributeNames::href)));
|
||||
set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request));
|
||||
} else if (m_relationship & Relationship::DNSPrefetch) {
|
||||
ResourceLoader::the().prefetch_dns(document().parse_url(get_attribute_value(HTML::AttributeNames::href)));
|
||||
ResourceLoader::the().prefetch_dns(document().encoding_parse_url(get_attribute_value(HTML::AttributeNames::href)));
|
||||
} else if (m_relationship & Relationship::Preconnect) {
|
||||
ResourceLoader::the().preconnect(document().parse_url(get_attribute_value(HTML::AttributeNames::href)));
|
||||
ResourceLoader::the().preconnect(document().encoding_parse_url(get_attribute_value(HTML::AttributeNames::href)));
|
||||
} else if (m_relationship & Relationship::Icon) {
|
||||
auto favicon_url = document().parse_url(href());
|
||||
auto favicon_url = document().encoding_parse_url(href());
|
||||
auto favicon_request = LoadRequest::create_for_url_on_page(favicon_url, &document().page());
|
||||
set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, favicon_request));
|
||||
}
|
||||
@@ -261,6 +261,8 @@ GC::Ptr<Fetch::Infrastructure::Request> HTMLLinkElement::create_link_request(HTM
|
||||
// FIXME: 2. If options's destination is null, then return null.
|
||||
|
||||
// 3. Let url be the result of encoding-parsing a URL given options's href, relative to options's base URL.
|
||||
// FIXME: Spec issue: We should be parsing this URL relative to a document or environment settings object.
|
||||
// https://github.com/whatwg/html/issues/9715
|
||||
auto url = options.base_url.complete_url(options.href);
|
||||
|
||||
// 4. If url is failure, then return null.
|
||||
|
||||
Reference in New Issue
Block a user