[wp-trac] [WordPress Trac] #34302: get_rest_url() should not include a trailing slash by default
WordPress Trac
noreply at wordpress.org
Wed Oct 14 19:04:24 UTC 2015
#34302: get_rest_url() should not include a trailing slash by default
--------------------------+-------------------------
Reporter: johnbillion | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.4
Component: REST API | Version: trunk
Severity: normal | Keywords: needs-patch
Focuses: |
--------------------------+-------------------------
Core's various `*_url()` functions return URLs without a trailing slash
unless the `$path` argument specifies one. `get_rest_url()` is the
exception as it includes a trailing slash by default when no `$path` is
specified.
{{{
echo get_home_url() // http://example.com
echo get_rest_url() // http://example.com/wp-json/
}}}
This creates a problem when a REST API client requests `http://example.com
/wp-json/` to retrieve a list of routes and then concatenates one of the
available routes onto the REST API endpoint, resulting in a double slash
in the path, which in turn results in a 404 when requested.
An example of an affected client is the [https://wordpress.org/plugins
/rest-api-console/ REST API Console plugin].
Unfortunately this also affects some of the internals of the REST API.
Patch in progress.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34302>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list