Skip to content

Commit f828649

Browse files
authored
Merge pull request #457 from WordPress/fix/456-rest-route
Fix REST API support for plain permalinks.
2 parents 525eeb8 + 9bd8c1a commit f828649

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎modules/images/webp-uploads/fallback.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ window.wpPerfLab = window.wpPerfLab || {};
5454
}
5555

5656
var jsonp = document.createElement( 'script' );
57-
jsonp.src = restApi + 'wp/v2/media/?_fields=id,media_details&_jsonp=wpPerfLab.webpUploadsFallbackWebpImages&per_page=100&include=' + pageIds.join( ',' );
57+
var restPath = 'wp/v2/media/?_fields=id,media_details&_jsonp=wpPerfLab.webpUploadsFallbackWebpImages&per_page=100&include=' + pageIds.join( ',' );
58+
if ( -1 !== restApi.indexOf( '?' ) ) {
59+
restPath = restPath.replace( '?', '&' );
60+
}
61+
jsonp.src = restApi + restPath;
5862
document.body.appendChild( jsonp );
5963
}
6064
};
@@ -69,7 +73,7 @@ window.wpPerfLab = window.wpPerfLab || {};
6973
loadMediaDetails( mutationList[i].addedNodes );
7074
}
7175
} );
72-
76+
7377
observer.observe( document.body, {
7478
subtree: true,
7579
childList: true,

0 commit comments

Comments
 (0)