Changeset 41126
- Timestamp:
- 07/24/2017 08:45:23 PM (7 years ago)
- Location:
- branches/4.8
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.8
-
branches/4.8/src/wp-includes/js/wp-api.js
r40364 r41126 1113 1113 'PostsTags': 'PostTags' 1114 1114 } 1115 }; 1115 }, 1116 1117 modelEndpoints = routeModel.get( 'modelEndpoints' ), 1118 modelRegex = new RegExp( '(?:.*[+)]|\/(' + modelEndpoints.join( '|' ) + '))$' ); 1116 1119 1117 1120 /** … … 1138 1141 ) { 1139 1142 1140 // Single items end with a regex (or the special case 'me').1141 if ( /(?:.*[+)]|\/me)$/.test( index ) ) {1143 // Single items end with a regex, or a special case word. 1144 if ( modelRegex.test( index ) ) { 1142 1145 modelRoutes.push( { index: index, route: route } ); 1143 1146 } else { … … 1361 1364 var endpoint, attributes = {}, deferred, promise; 1362 1365 1363 args = args || {}; 1364 attributes.apiRoot = args.apiRoot || wpApiSettings.root || '/wp-json'; 1365 attributes.versionString = args.versionString || wpApiSettings.versionString || 'wp/v2/'; 1366 attributes.schema = args.schema || null; 1366 args = args || {}; 1367 attributes.apiRoot = args.apiRoot || wpApiSettings.root || '/wp-json'; 1368 attributes.versionString = args.versionString || wpApiSettings.versionString || 'wp/v2/'; 1369 attributes.schema = args.schema || null; 1370 attributes.modelEndpoints = args.modelEndpoints || [ 'me', 'settings' ]; 1367 1371 if ( ! attributes.schema && attributes.apiRoot === wpApiSettings.root && attributes.versionString === wpApiSettings.versionString ) { 1368 1372 attributes.schema = wpApiSettings.schema; -
branches/4.8/tests/qunit/fixtures/wp-api.js
r40364 r41126 25 25 'wp-json/wp/v2/status': mockedApiResponse.StatusModel, 26 26 'wp-json/wp/v2/type': mockedApiResponse.TypeModel, 27 'wp-json/js-widgets/v1/': jsWidgetsEndpointSchema 27 'wp-json/js-widgets/v1/': jsWidgetsEndpointSchema, 28 'wp-json/wp/v2/users/me': mockedApiResponse.me, 29 'wp-json/wp/v2/settings': mockedApiResponse.settings 28 30 }; 29 31 -
branches/4.8/tests/qunit/wp-includes/js/wp-api.js
r40364 r41126 116 116 'Post', 117 117 'Tag', 118 'User' 118 'User', 119 'UsersMe', 120 'Settings' 119 121 ]; 120 122 … … 131 133 theModel.fetch().done( function( ) { 132 134 var theModel2 = new wp.api.models[ className ](); 133 theModel2.set( 'id', theModel.attributes [0].id );135 theModel2.set( 'id', theModel.attributes.id ); 134 136 theModel2.fetch().done( function() { 135 137 136 138 // We were able to retrieve the model. 137 139 assert.equal( 138 theModel.attributes [0].id,140 theModel.attributes.id, 139 141 theModel2.get( 'id' ) , 140 142 'We should be able to get a ' + className
Note: See TracChangeset
for help on using the changeset viewer.