File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -16,18 +16,20 @@ const parseLinkHeader = require( 'parse-link-header' );
16
16
* @returns {String } The URL of the located API root
17
17
*/
18
18
function locateAPIRootHeader ( response ) {
19
+ // See https://developer.wordpress.org/rest-api/using-the-rest-api/discovery/
20
+ const rel = 'https://api.w.org/' ;
21
+
19
22
// Extract & parse the response link headers
20
23
const link = response . link || ( response . headers && response . headers . link ) ;
21
24
const headers = parseLinkHeader ( link ) ;
22
25
23
- // See https://developer.wordpress.org/rest-api/using-the-rest-api/discovery/
24
- const apiHeader = headers && headers [ 'https://api.w.org/' ] ;
26
+ const apiHeader = headers && headers [ rel ] ;
25
27
26
28
if ( apiHeader && apiHeader . url ) {
27
29
return apiHeader . url ;
28
30
}
29
31
30
- throw new Error ( ' No header link found with rel="https://api.w.org/"' ) ;
32
+ throw new Error ( ` No header link found with rel="${ rel } "` ) ;
31
33
}
32
34
33
35
module . exports = {
You can’t perform that action at this time.
0 commit comments