WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/11/2020 03:20:05 AM (10 months ago)
Author:
kadamwhite
Message:

REST API: Match REST API routes on namespace before performing regex checks.

Rule out groups of API endpoints by simple namespace string comparison to reduce the number of regex checks necessary when matching a route.

Props TimothyBlynJacobs.
Fixes #48530.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-server.php

    r47239 r47260  
    14321432    }
    14331433
     1434    /**
     1435     * @ticket 48530
     1436     */
     1437    public function test_get_routes_respects_namespace_parameter() {
     1438        $routes = rest_get_server()->get_routes( 'oembed/1.0' );
     1439
     1440        foreach ( $routes as $route => $handlers ) {
     1441            $this->assertStringStartsWith( '/oembed/1.0', $route );
     1442        }
     1443    }
     1444
    14341445    public function _validate_as_integer_123( $value, $request, $key ) {
    14351446        if ( ! is_int( $value ) ) {
Note: See TracChangeset for help on using the changeset viewer.