WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/13/2016 06:34:12 PM (3 years ago)
Author:
ocean90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r38174 r38255  
    28402840                }
    28412841
    2842                 if ( 'dns-prefetch' === $relation_type ) {
    2843                     $url = '//' . $parsed['host'];
    2844                 } else if ( ! empty( $parsed['scheme'] ) ) {
     2842                if ( 'preconnect' === $relation_type && ! empty( $parsed['scheme'] ) ) {
    28452843                    $url = $parsed['scheme'] . '://' . $parsed['host'];
    28462844                } else {
    2847                     $url = $parsed['host'];
     2845                    // Use protocol-relative URLs for dns-prefetch or if scheme is missing.
     2846                    $url = '//' . $parsed['host'];
    28482847                }
    28492848            }
Note: See TracChangeset for help on using the changeset viewer.