Skip to content

Commit 3db90d9

Browse files
nlfisaacs
authored andcommitted
allow for passing object keys to searchopts to allow pagination
PR-URL: #2303 Credit: @nlf Close: #2303 Reviewed-by: @isaacs
1 parent 0ef25b6 commit 3db90d9

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

lib/utils/flat-options.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
const log = require('npmlog')
55
const crypto = require('crypto')
6+
const querystring = require('querystring')
67
const npmSession = crypto.randomBytes(8).toString('hex')
78
log.verbose('npm-session', npmSession)
89
const { join } = require('path')
@@ -92,7 +93,7 @@ const flatten = obj => ({
9293
description: obj.description,
9394
exclude: obj.searchexclude,
9495
limit: obj.searchlimit || 20,
95-
opts: obj.searchopts,
96+
opts: querystring.parse(obj.searchopts),
9697
staleness: obj.searchstaleness,
9798
},
9899

tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ Object {
9595
"description": "description",
9696
"exclude": "searchexclude",
9797
"limit": "searchlimit",
98-
"opts": "searchopts",
98+
"opts": Null Object {
99+
"from": "1",
100+
},
99101
"staleness": "searchstaleness",
100102
},
101103
"sendMetrics": "send-metrics",

test/lib/utils/flat-options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class MockConfig {
6565
description: 'description',
6666
searchexclude: 'searchexclude',
6767
searchlimit: 'searchlimit',
68-
searchopts: 'searchopts',
68+
searchopts: 'from=1',
6969
searchstaleness: 'searchstaleness',
7070
'dry-run': 'dry-run',
7171
'engine-strict': 'engine-strict',

0 commit comments

Comments
 (0)