WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/13/2016 06:39:39 PM (5 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.

Merge of [38255] to the 4.6 branch.

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

Location:
branches/4.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

  • branches/4.6/src/wp-includes/general-template.php

    r38174 r38256  
    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.