mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
REST API: Remove trailing slashes when preloading requests and add unit tests for it.
Props antonvlasenko. Fixes #51636. git-svn-id: https://develop.svn.wordpress.org/trunk@51648 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -954,6 +954,31 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
$GLOBALS['wp_rest_server'] = $rest_server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 51636
|
||||
*/
|
||||
function test_rest_preload_api_request_removes_trailing_slashes() {
|
||||
$rest_server = $GLOBALS['wp_rest_server'];
|
||||
$GLOBALS['wp_rest_server'] = null;
|
||||
|
||||
$preload_paths = array(
|
||||
'/wp/v2/types//',
|
||||
array( '/wp/v2/media///', 'OPTIONS' ),
|
||||
'////',
|
||||
);
|
||||
|
||||
$preload_data = array_reduce(
|
||||
$preload_paths,
|
||||
'rest_preload_api_request',
|
||||
array()
|
||||
);
|
||||
|
||||
$this->assertSame( array_keys( $preload_data ), array( '/wp/v2/types', 'OPTIONS', '/' ) );
|
||||
$this->assertArrayHasKey( '/wp/v2/media', $preload_data['OPTIONS'] );
|
||||
|
||||
$GLOBALS['wp_rest_server'] = $rest_server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 40614
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user