From 7fc3aae637a0259caa07801d9d373eedb521f610 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 20 Aug 2021 23:44:57 +0000 Subject: [PATCH] REST API: Remove trailing slashes when preloading requests and add unit tests for it. Props antonvlasenko. Fixes #51636. Built from https://develop.svn.wordpress.org/trunk@51648 git-svn-id: http://core.svn.wordpress.org/trunk@51254 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api.php | 5 +++++ wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php index 7480fd5c64..675c545ce1 100644 --- a/wp-includes/rest-api.php +++ b/wp-includes/rest-api.php @@ -2818,6 +2818,11 @@ function rest_preload_api_request( $memo, $path ) { } } + $path = untrailingslashit( $path ); + if ( empty( $path ) ) { + $path = '/'; + } + $path_parts = parse_url( $path ); if ( false === $path_parts ) { return $memo; diff --git a/wp-includes/version.php b/wp-includes/version.php index 068dffae2e..4e38a362ca 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51647'; +$wp_version = '5.9-alpha-51648'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.