WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #38873


Ignore:
Timestamp:
11/20/2016 12:40:08 AM (4 years ago)
Author:
jnylen0
Comment:

Similarly, the official API console is broken on my site due to a duplicated slash in between the REST prefix and the namespace (wp-json//wp/v2/posts):

https://nylen.io/rest-api-console-double-slash.png

Other cases:

  1. //wp-json/wp/v2/posts: works.
  2. //wp-json/wp//v2/posts: does not work. (Debatable whether it should, as wp/v2 is a valid namespace but wp//v2 is not.)
  3. //wp-json/wp/v2//posts: does not work.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #38873 – Description

    initial v1  
    1 Current, a request to the API with rewrite rules enabled doesn't differenentiate URLs with trailing slashes just as `http://localhost:8080/wp-json/wp/v2/` vs `http://localhost:8080/wp-json/wp/v2`, this seems to be a property to WP_Rewrite / class WP to split off the trailing slash always.
     1Current, a request to the API with rewrite rules enabled doesn't differentiate URLs with trailing slashes just as `http://localhost:8080/wp-json/wp/v2/` vs `http://localhost:8080/wp-json/wp/v2`, this seems to be a property to WP_Rewrite / class WP to split off the trailing slash always.
    22
    33However, when making requests do `http://localhost:8080/?rest_route=/wp/v2/` the trailing slash is not stripped, as it doesn't go through the same transformation in `class WP`. I think it's safe to always untrailingslash the requested URL in the REST API, for matching purposes.