mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-27 17:47:34 +09:00
Enhance DNS prefetching by resolving URIs against the document base URI
This commit is contained in:
parent
ad5d1d60e5
commit
b913fa62d9
1 changed files with 12 additions and 9 deletions
|
|
@ -923,15 +923,15 @@ nsContentSink::PrefetchDNS(const nsAString &aHref)
|
||||||
{
|
{
|
||||||
nsAutoString hostname;
|
nsAutoString hostname;
|
||||||
|
|
||||||
if (StringBeginsWith(aHref, NS_LITERAL_STRING("//"))) {
|
// Resolve against the document base URI so relative and scheme-relative
|
||||||
hostname = Substring(aHref, 2);
|
// Link header values can still extract a hostname for speculation.
|
||||||
}
|
const nsACString& charset = mDocument->GetDocumentCharacterSet();
|
||||||
else {
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsCOMPtr<nsIURI> uri;
|
NS_NewURI(getter_AddRefs(uri), aHref,
|
||||||
NS_NewURI(getter_AddRefs(uri), aHref);
|
charset.IsEmpty() ? nullptr : PromiseFlatCString(charset).get(),
|
||||||
if (!uri) {
|
mDocument->GetDocBaseURI());
|
||||||
return;
|
|
||||||
}
|
if (uri) {
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
bool isLocalResource = false;
|
bool isLocalResource = false;
|
||||||
rv = NS_URIChainHasFlags(uri, nsIProtocolHandler::URI_IS_LOCAL_RESOURCE,
|
rv = NS_URIChainHasFlags(uri, nsIProtocolHandler::URI_IS_LOCAL_RESOURCE,
|
||||||
|
|
@ -941,6 +941,9 @@ nsContentSink::PrefetchDNS(const nsAString &aHref)
|
||||||
uri->GetHost(host);
|
uri->GetHost(host);
|
||||||
CopyUTF8toUTF16(host, hostname);
|
CopyUTF8toUTF16(host, hostname);
|
||||||
}
|
}
|
||||||
|
} else if (aHref.FindChar('/') == kNotFound && aHref.FindChar(':') == kNotFound) {
|
||||||
|
// Support a bare hostname token in Link headers.
|
||||||
|
hostname = aHref;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hostname.IsEmpty() && nsHTMLDNSPrefetch::IsAllowed(mDocument)) {
|
if (!hostname.IsEmpty() && nsHTMLDNSPrefetch::IsAllowed(mDocument)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue