id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,focuses 44745,REST API: incorrect slashes in url if parent empty,nicomollet,adamsilverstein,"Hello everyone, I am using the WP.API with a custom versionString: ""wc/v2/"" from WooCommerce. When fetching ProductCategories (or any other collections with two capital letters), the url called is: http://websiteurl/wp-json/wc/v2/products//categories Example of the code I use, to be able to reproduce the error: {{{ wp.api.init({'versionString': 'wc/v2/'}); var productcategories = new wp.api.collections.ProductsCategories(); productcategories.fetch().done( function() { productcategories.each( function( productcategory ) { console.log( productcategory.attributes ); } ); } ); }}} My tentative fix is the following: In wp-api.js, line 1406 The parent is sometimes empty, leading to two consecutive slashes. {{{ // Function that returns a constructed url passed on the parent. url: function() { return routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) + parentName + '/' + this.parent + '/' + routeName; }, }}} should be replaced by: {{{ // Function that returns a constructed url passed on the parent. url: function() { return routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) + parentName + '/' + ( ( _.isUndefined( this.get( 'parent' ) ) || 0 === this.get( 'parent' ) ) ? ( _.isUndefined( this.get( 'parent_post' ) ) ? '' : this.get( 'parent_post' ) + '/' ) : this.get( 'parent' ) + '/' ) + routeName; }, }}} Thank you very much Nicolas ",defect (bug),closed,normal,5.6,REST API,4.9.8,normal,fixed,has-patch reporter-feedback commit,,javascript