Skip to content

Commit 4bf3a31

Browse files
committed
Switch back from parse-link-header to li
parse-link-header depends on url, which adds considerable weight to the bundle size with no commensurate benefit
1 parent 1ef5b3b commit 4bf3a31

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

lib/autodiscovery.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
'use strict';
88

9-
const parseLinkHeader = require( 'parse-link-header' );
9+
const parseLinkHeader = require( 'li' ).parse;
1010

1111
/**
1212
* Attempt to locate a `rel="https://api.w.org"` link relation header
@@ -25,8 +25,8 @@ function locateAPIRootHeader( response ) {
2525

2626
const apiHeader = headers && headers[ rel ];
2727

28-
if ( apiHeader && apiHeader.url ) {
29-
return apiHeader.url;
28+
if ( apiHeader ) {
29+
return apiHeader;
3030
}
3131

3232
throw new Error( `No header link found with rel="${ rel }"` );

lib/http-transport.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'use strict';
55

66
const agent = require( 'superagent' );
7-
const parseLinkHeader = require( 'parse-link-header' );
7+
const parseLinkHeader = require( 'li' ).parse;
88

99
const WPRequest = require( './constructors/wp-request' );
1010
const checkMethodSupport = require( './util/check-method-support' );
@@ -149,7 +149,7 @@ function createPaginationObject( result, options, httpTransport ) {
149149
_paging.next = new WPRequest( {
150150
...options,
151151
transport: httpTransport,
152-
endpoint: links.next.url,
152+
endpoint: links.next,
153153
} );
154154
}
155155

@@ -158,7 +158,7 @@ function createPaginationObject( result, options, httpTransport ) {
158158
_paging.prev = new WPRequest( {
159159
...options,
160160
transport: httpTransport,
161-
endpoint: links.prev.url,
161+
endpoint: links.prev,
162162
} );
163163
}
164164

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"jest": "^23.6.0",
7979
"jsdoc": "^3.4.3",
8080
"kramed": "^0.5.6",
81+
"li": "^1.3.0",
8182
"load-grunt-tasks": "^3.5.0",
8283
"lodash.reduce": "^4.6.0",
8384
"minami": "^1.2.3",

0 commit comments

Comments
 (0)