Skip to content

Commit fd5a1c9

Browse files
committed
Require Node.js 18
1 parent cc232cb commit fd5a1c9

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

Diff for: .github/workflows/main.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13+
- 20
1314
- 18
14-
- 16
15-
- 14
1615
steps:
1716
- uses: actions/checkout@v4
1817
- uses: actions/setup-node@v4

Diff for: base.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {includeKeys} from 'filter-obj';
55
const isNullOrUndefined = value => value === null || value === undefined;
66

77
// eslint-disable-next-line unicorn/prefer-code-point
8-
const strictUriEncode = string => encodeURIComponent(string).replace(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
8+
const strictUriEncode = string => encodeURIComponent(string).replaceAll(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
99

1010
const encodeFragmentIdentifier = Symbol('encodeFragmentIdentifier');
1111

@@ -87,7 +87,7 @@ function encoderForArrayFormat(options) {
8787
case 'comma':
8888
case 'separator':
8989
case 'bracket-separator': {
90-
const keyValueSep = options.arrayFormat === 'bracket-separator'
90+
const keyValueSeparator = options.arrayFormat === 'bracket-separator'
9191
? '[]='
9292
: '=';
9393

@@ -104,7 +104,7 @@ function encoderForArrayFormat(options) {
104104
value = value === null ? '' : value;
105105

106106
if (result.length === 0) {
107-
return [[encode(key, options), keyValueSep, encode(value, options)].join('')];
107+
return [[encode(key, options), keyValueSeparator, encode(value, options)].join('')];
108108
}
109109

110110
return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
@@ -353,7 +353,7 @@ export function parse(query, options) {
353353
continue;
354354
}
355355

356-
const parameter_ = options.decode ? parameter.replace(/\+/g, ' ') : parameter;
356+
const parameter_ = options.decode ? parameter.replaceAll('+', ' ') : parameter;
357357

358358
let [key, value] = splitOnFirst(parameter_, '=');
359359

@@ -395,10 +395,13 @@ export function stringify(object, options) {
395395
return '';
396396
}
397397

398-
options = {encode: true,
398+
options = {
399+
encode: true,
399400
strict: true,
400401
arrayFormat: 'none',
401-
arrayFormatSeparator: ',', ...options};
402+
arrayFormatSeparator: ',',
403+
...options,
404+
};
402405

403406
validateArrayFormatSeparator(options.arrayFormatSeparator);
404407

@@ -484,9 +487,7 @@ export function stringifyUrl(object, options) {
484487
};
485488

486489
let queryString = stringify(query, options);
487-
if (queryString) {
488-
queryString = `?${queryString}`;
489-
}
490+
queryString &&= `?${queryString}`;
490491

491492
let hash = getHash(object.url);
492493
if (typeof object.fragmentIdentifier === 'string') {

Diff for: benchmark.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ const TEST_URL = stringifyUrl({url: TEST_HOST, query: TEST_OBJECT});
2424

2525
// Creates a test case and adds it to the suite
2626
const defineTestCase = (methodName, input, options) => {
27-
const fn = queryString[methodName];
27+
const function_ = queryString[methodName];
2828
const label = options ? ` (${stringify(options)})` : '';
2929

30-
suite.add(methodName + label, () => fn(input, options || {}));
30+
suite.add(methodName + label, () => function_(input, options || {}));
3131
};
3232

3333
// Define all test cases

Diff for: package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"sideEffects": false,
1919
"engines": {
20-
"node": ">=14.16"
20+
"node": ">=18"
2121
},
2222
"scripts": {
2323
"benchmark": "node benchmark.js",
@@ -51,12 +51,12 @@
5151
"split-on-first": "^3.0.0"
5252
},
5353
"devDependencies": {
54-
"ava": "^5.1.0",
54+
"ava": "^6.1.1",
5555
"benchmark": "^2.1.4",
56-
"deep-equal": "^2.1.0",
57-
"fast-check": "^3.4.0",
58-
"tsd": "^0.25.0",
59-
"xo": "^0.54.2"
56+
"deep-equal": "^2.2.3",
57+
"fast-check": "^3.15.1",
58+
"tsd": "^0.30.7",
59+
"xo": "^0.57.0"
6060
},
6161
"tsd": {
6262
"compilerOptions": {

Diff for: test/parse-url.js

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import test from 'ava';
22
import queryString from '../index.js';
33

44
test('handles strings with query string', t => {
5-
console.log('f', queryString.parseUrl('https://foo.bar#top?foo=bar'));
65
t.deepEqual(queryString.parseUrl('https://foo.bar#top?foo=bar'), {url: 'https://foo.bar', query: {}});
76
t.deepEqual(queryString.parseUrl('https://foo.bar?foo=bar&foo=baz#top'), {url: 'https://foo.bar', query: {foo: ['bar', 'baz']}});
87
t.deepEqual(queryString.parseUrl('https://foo.bar?foo=bar&foo=baz'), {url: 'https://foo.bar', query: {foo: ['bar', 'baz']}});

0 commit comments

Comments
 (0)