mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 09:07:59 +01:00
REST API: Remove trailing slashes when preloading requests and there is a query string.
Follow-up to [51648], see #51636. Props antonvlasenko, swissspidy, spacedmonkey. Fixes #57048. Built from https://develop.svn.wordpress.org/trunk@59457 git-svn-id: http://core.svn.wordpress.org/trunk@58843 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c67b970348
commit
8f303471a4
@ -2935,6 +2935,7 @@ function rest_preload_api_request( $memo, $path ) {
|
||||
}
|
||||
}
|
||||
|
||||
// Remove trailing slashes at the end of the REST API path (query part).
|
||||
$path = untrailingslashit( $path );
|
||||
if ( empty( $path ) ) {
|
||||
$path = '/';
|
||||
@ -2945,6 +2946,14 @@ function rest_preload_api_request( $memo, $path ) {
|
||||
return $memo;
|
||||
}
|
||||
|
||||
if ( isset( $path_parts['path'] ) && '/' !== $path_parts['path'] ) {
|
||||
// Remove trailing slashes from the "path" part of the REST API path.
|
||||
$path_parts['path'] = untrailingslashit( $path_parts['path'] );
|
||||
$path = str_contains( $path, '?' ) ?
|
||||
$path_parts['path'] . '?' . ( $path_parts['query'] ?? '' ) :
|
||||
$path_parts['path'];
|
||||
}
|
||||
|
||||
$request = new WP_REST_Request( $method, $path_parts['path'] );
|
||||
if ( ! empty( $path_parts['query'] ) ) {
|
||||
parse_str( $path_parts['query'], $query_params );
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.8-alpha-59456';
|
||||
$wp_version = '6.8-alpha-59457';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user