Opened 7 years ago
Closed 5 years ago
#44825 closed defect (bug) (invalid)
get_rest_url does not respect query args added to get_home_url
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | REST API | Keywords: | reporter-feedback close |
Focuses: | Cc: |
Description
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/rest-api.php#L321
This line appends the rest $path
to the result of get_home_url
, which can be modified by any plugin to have query arguments.
An easy way to fix it is to just append the $path to the parameter to get_home_url itself
<?php //line 315 and further if ( $wp_rewrite->using_index_permalinks() ) { $url = get_home_url( $blog_id, $wp_rewrite->index . '/' . rest_get_url_prefix() . $path, $scheme ); } else { $url = get_home_url( $blog_id, rest_get_url_prefix() . $path, $scheme ); }
Hope this helps.
Change History (6)
This ticket was mentioned in Slack in #core-restapi by timothybjacobs. View the logs.
6 years ago
Note: See
TracTickets for help on using
tickets.
@distinct could you expand a bit more on your use case? Does your home URL always have query parameters in order for your website to load at all?
My initial thoughts are that particular query params on the home URL shouldn't be added to the REST API as well. There is also a high chance of conflicting with the various REST API collection params.