Changeset 43771
- Timestamp:
- 10/19/2018 06:32:03 PM (6 years ago)
- Location:
- branches/5.0
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.0
-
branches/5.0/src/wp-includes/js/api-request.js
r41351 r43771 23 23 var url = options.url; 24 24 var path = options.path; 25 var namespaceTrimmed, endpointTrimmed ;25 var namespaceTrimmed, endpointTrimmed, apiRoot; 26 26 var headers, addNonceHeader, headerName; 27 27 … … 39 39 } 40 40 if ( typeof path === 'string' ) { 41 url = wpApiSettings.root + path.replace( /^\//, '' ); 41 apiRoot = wpApiSettings.root; 42 path = path.replace( /^\//, '' ); 43 44 // API root may already include query parameter prefix if site is 45 // configured to use plain permalinks. 46 if ( 'string' === typeof apiRoot && -1 !== apiRoot.indexOf( '?' ) ) { 47 path = path.replace( '?', '&' ); 48 } 49 50 url = apiRoot + path; 42 51 } 43 52 -
branches/5.0/tests/qunit/wp-includes/js/api-request.js
r41224 r43771 141 141 assert.deepEqual( wp.apiRequest.buildAjaxOptions( { 142 142 namespace: '/wp/v2/', 143 endpoint: '/posts '143 endpoint: '/posts?orderby=title' 144 144 } ), { 145 url: 'http://localhost/index.php?rest_route=/wp/v2/posts ',145 url: 'http://localhost/index.php?rest_route=/wp/v2/posts&orderby=title', 146 146 headers: nonceHeader 147 147 } );
Note: See TracChangeset
for help on using the changeset viewer.