#57048 closed defect (bug) (fixed)
Handle trailing slashes in rest_preload_api_request
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.8 | Priority: | normal |
| Severity: | normal | Version: | 5.0 |
| Component: | REST API | Keywords: | has-patch has-unit-tests has-test-info commit |
| Focuses: | rest-api | Cc: |
Description
When passing a path to rest_preload_api_request that ends in query string, ensure that the parsed path also is untrailingslashit. Follow up to #51636
Change History (12)
This ticket was mentioned in βPR #6927 on βWordPress/wordpress-develop by β@antonvlasenko.
18 months ago
#2
- Keywords has-patch has-unit-tests added; needs-patch removed
Trac ticket: https://core.trac.wordpress.org/ticket/57048
#3
@
18 months ago
- Keywords has-testing-info added
The βproposed PR updates the rest_preload_api_request function to remove trailing slashes from path parth of the request when preloading data for a specified REST API path.
Before patch:
Preloading /wp/v2/types//?media// would return an array with preloaded data keyed as /wp/v2/types//?media. Only slashes at the end of the path were removed.
After patch:
The path would be /wp/v2/types?media.
Steps to test this PR:
- Login to the admin panel.
- Edit an existing post or create a new one and then click
Edit. - Open the dev tools, inspect the source code of the page. You should see a call to the
wp.apiFetch.createPreloadingMiddleware()function and the preloaded data passed as an argument of that function. Typical preloaded requests are:/wp/v2/types?context=view/wp/v2/taxonomies?context=view/wp/v2/blocks?context=edit&per_page=-1/wp/v2/posts/<post-ID>?context=edit/wp/v2/types/post?context=edit/wp/v2/settings
I'm working on a patch for this issue.