Script Loader: Fix protocol-relative URLs for the preconnect relation type.

`wp_resource_hints()` parses the URL for the `preconnect` and `dns-prefetch` relation types to ensure correct values for both. While protocol-relative URLs are supported for `dns-prefetch`, the double slash was lost for `preconnect`.

Props swissspidy, peterwilsoncc.
Props azaozz for review.
Fixes #37652.

git-svn-id: https://develop.svn.wordpress.org/trunk@38255 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling
2016-08-13 18:34:12 +00:00
parent 19a85950ad
commit a0aba9dc44
2 changed files with 69 additions and 4 deletions
+3 -4
View File
@@ -2839,12 +2839,11 @@ function wp_resource_hints() {
continue;
}
if ( 'dns-prefetch' === $relation_type ) {
$url = '//' . $parsed['host'];
} else if ( ! empty( $parsed['scheme'] ) ) {
if ( 'preconnect' === $relation_type && ! empty( $parsed['scheme'] ) ) {
$url = $parsed['scheme'] . '://' . $parsed['host'];
} else {
$url = $parsed['host'];
// Use protocol-relative URLs for dns-prefetch or if scheme is missing.
$url = '//' . $parsed['host'];
}
}