Make WordPress Core

Changeset 49390


Ignore:
Timestamp:
10/29/2020 06:30:41 PM (4 years ago)
Author:
adamsilverstein
Message:

REST API: JS Client - improve collection route construction for empty parents.

Fix an issue where the constructed path for hierarchical collections could contain a double slash ("") when items contained empty parents, causing an error.

Props nicomollet.
Fixes #44745.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/api.js

    r49075 r49390  
    14131413                        url: function() {
    14141414                            return routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) +
    1415                                     parentName + '/' + this.parent + '/' +
    1416                                     routeName;
     1415                                parentName + '/' +
     1416                                ( ( _.isUndefined( this.parent ) || '' === this.parent ) ?
     1417                                    ( _.isUndefined( this.get( 'parent_post' ) ) ? '' : this.get( 'parent_post' ) + '/' ) :
     1418                                    this.parent + '/' ) +
     1419                                routeName;
    14171420                        },
    14181421
Note: See TracChangeset for help on using the changeset viewer.