@common.js/query-string 8.1.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  The [query-string](https://www.npmjs.com/package/query-string) package exported as CommonJS modules.
4
4
 
5
- Exported from [query-string@8.1.0](https://www.npmjs.com/package/query-string/v/8.1.0) using https://github.com/etienne-martin/common.js.
5
+ Exported from [query-string@9.0.0](https://www.npmjs.com/package/query-string/v/9.0.0) using https://github.com/etienne-martin/common.js.
package/base.d.ts CHANGED
@@ -220,7 +220,7 @@ export function parseUrl(url: string, options?: ParseOptions): ParsedUrl;
220
220
 
221
221
  export type StringifyOptions = {
222
222
  /**
223
- Strictly encode URI components with [`strict-uri-encode`](https://github.com/kevva/strict-uri-encode). It uses [`encodeURIComponent`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) if set to `false`. You probably [don't care](https://github.com/sindresorhus/query-string/issues/42) about this option.
223
+ Strictly encode URI components. It uses [`encodeURIComponent`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) if set to `false`. You probably [don't care](https://github.com/sindresorhus/query-string/issues/42) about this option.
224
224
 
225
225
  @default true
226
226
  */
@@ -412,7 +412,7 @@ export type StringifyOptions = {
412
412
  readonly skipEmptyString?: boolean;
413
413
  };
414
414
 
415
- export type Stringifiable = string | boolean | number | null | undefined; // eslint-disable-line @typescript-eslint/ban-types
415
+ export type Stringifiable = string | boolean | number | bigint | null | undefined; // eslint-disable-line @typescript-eslint/ban-types
416
416
 
417
417
  export type StringifiableRecord = Record<
418
418
  string,
package/base.js CHANGED
@@ -130,7 +130,7 @@ var isNullOrUndefined = function(value) {
130
130
  };
131
131
  // eslint-disable-next-line unicorn/prefer-code-point
132
132
  var strictUriEncode = function(string) {
133
- return encodeURIComponent(string).replace(/[!'()*]/g, function(x) {
133
+ return encodeURIComponent(string).replaceAll(/[!'()*]/g, function(x) {
134
134
  return "%".concat(x.charCodeAt(0).toString(16).toUpperCase());
135
135
  });
136
136
  };
@@ -221,7 +221,7 @@ function encoderForArrayFormat(options) {
221
221
  case "separator":
222
222
  case "bracket-separator":
223
223
  {
224
- var keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "=";
224
+ var keyValueSeparator = options.arrayFormat === "bracket-separator" ? "[]=" : "=";
225
225
  return function(key) {
226
226
  return function(result, value) {
227
227
  if (value === undefined || options.skipNull && value === null || options.skipEmptyString && value === "") {
@@ -233,7 +233,7 @@ function encoderForArrayFormat(options) {
233
233
  return [
234
234
  [
235
235
  encode(key, options),
236
- keyValueSep,
236
+ keyValueSeparator,
237
237
  encode(value, options)
238
238
  ].join("")
239
239
  ];
@@ -465,7 +465,7 @@ function parse(query, options) {
465
465
  if (parameter === "") {
466
466
  continue;
467
467
  }
468
- var parameter_ = options.decode ? parameter.replace(/\+/g, " ") : parameter;
468
+ var parameter_ = options.decode ? parameter.replaceAll("+", " ") : parameter;
469
469
  var ref = _slicedToArray((0, _splitOnFirst.default)(parameter_, "="), 2), key = ref[0], value = ref[1];
470
470
  if (key === undefined) {
471
471
  key = parameter_;
@@ -543,12 +543,7 @@ function parse(query, options) {
543
543
  // eslint-disable-next-line unicorn/no-array-reduce
544
544
  return (options.sort === true ? Object.keys(returnValue).sort() : Object.keys(returnValue).sort(options.sort)).reduce(function(result, key) {
545
545
  var value = returnValue[key];
546
- if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) {
547
- // Sort object keys, not values
548
- result[key] = keysSorter(value);
549
- } else {
550
- result[key] = value;
551
- }
546
+ result[key] = Boolean(value) && typeof value === "object" && !Array.isArray(value) ? keysSorter(value) : value;
552
547
  return result;
553
548
  }, Object.create(null));
554
549
  }
@@ -641,11 +636,9 @@ function stringifyUrl(object, options) {
641
636
  sort: false
642
637
  }), object.query);
643
638
  var queryString = stringify(query, options);
644
- if (queryString) {
645
- queryString = "?".concat(queryString);
646
- }
639
+ queryString && (queryString = "?".concat(queryString));
647
640
  var hash = getHash(object.url);
648
- if (object.fragmentIdentifier) {
641
+ if (typeof object.fragmentIdentifier === "string") {
649
642
  var urlObjectForFragmentEncode = new URL(url);
650
643
  urlObjectForFragmentEncode.hash = object.fragmentIdentifier;
651
644
  hash = options[encodeFragmentIdentifier] ? urlObjectForFragmentEncode.hash : "#".concat(object.fragmentIdentifier);
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@common.js/query-string",
3
- "version": "8.1.0",
3
+ "version": "9.0.0",
4
4
  "description": "query-string package exported as CommonJS modules",
5
5
  "license": "MIT",
6
6
  "repository": "etienne-martin/common.js",
7
7
  "funding": "https://github.com/sponsors/sindresorhus",
8
8
  "type": "commonjs",
9
+ "sideEffects": false,
9
10
  "engines": {
10
- "node": ">=14.16"
11
+ "node": ">=18"
11
12
  },
12
13
  "scripts": {
13
14
  "benchmark": "node benchmark.js",
@@ -25,12 +26,12 @@
25
26
  "@common.js/split-on-first": "^3.0.0"
26
27
  },
27
28
  "devDependencies": {
28
- "ava": "^5.1.0",
29
+ "ava": "^6.1.1",
29
30
  "benchmark": "^2.1.4",
30
- "deep-equal": "^2.1.0",
31
- "fast-check": "^3.4.0",
32
- "tsd": "^0.25.0",
33
- "xo": "^0.53.1"
31
+ "deep-equal": "^2.2.3",
32
+ "fast-check": "^3.15.1",
33
+ "tsd": "^0.30.7",
34
+ "xo": "^0.57.0"
34
35
  },
35
36
  "tsd": {
36
37
  "compilerOptions": {