Make WordPress Core


Ignore:
Timestamp:
11/28/2017 07:09:43 AM (7 years ago)
Author:
rmccue
Message:

REST API: Ensure rest_url() consistently has leading slash.

rest_url() inconsistent addes slashes to the passed path depending on whether the site has pretty permalinks enabled. Apart from being inconsistent, this also caused the unit tests to fail when pretty permalinks are enabled.

Props frank-klein.
Fixes #42452. See #41451.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api.php

    r42000 r42250  
    308308    }
    309309
     310    $path = '/' . ltrim( $path, '/' );
     311
    310312    if ( is_multisite() && get_blog_option( $blog_id, 'permalink_structure' ) || get_option( 'permalink_structure' ) ) {
    311313        global $wp_rewrite;
     
    317319        }
    318320
    319         $url .= '/' . ltrim( $path, '/' );
     321        $url .= $path;
    320322    } else {
    321323        $url = trailingslashit( get_home_url( $blog_id, '', $scheme ) );
     
    325327            $url .= 'index.php';
    326328        }
    327 
    328         $path = '/' . ltrim( $path, '/' );
    329329
    330330        $url = add_query_arg( 'rest_route', $path, $url );
Note: See TracChangeset for help on using the changeset viewer.