Skip to content

Commit 387f94b

Browse files
chore(internal): add query string encoder (#1079)
1 parent c354baf commit 387f94b

File tree

14 files changed

+3462
-126
lines changed

14 files changed

+3462
-126
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@
2626
"dependencies": {
2727
"@types/node": "^18.11.18",
2828
"@types/node-fetch": "^2.6.4",
29-
"@types/qs": "^6.9.15",
3029
"abort-controller": "^3.0.0",
3130
"agentkeepalive": "^4.2.1",
3231
"form-data-encoder": "1.7.2",
3332
"formdata-node": "^4.3.2",
34-
"node-fetch": "^2.6.7",
35-
"qs": "^6.10.3"
33+
"node-fetch": "^2.6.7"
3634
},
3735
"devDependencies": {
3836
"@swc/core": "^1.3.102",
@@ -43,6 +41,7 @@
4341
"eslint": "^8.49.0",
4442
"eslint-plugin-prettier": "^5.0.1",
4543
"eslint-plugin-unused-imports": "^3.0.0",
44+
"iconv-lite": "^0.6.3",
4645
"jest": "^29.4.0",
4746
"prettier": "^3.0.0",
4847
"ts-jest": "^29.1.0",

scripts/utils/denoify.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ async function denoify() {
102102
} else if (specifier.startsWith(pkgName + '/')) {
103103
// convert self-referencing module specifiers to relative paths
104104
specifier = file.getRelativePathAsModuleSpecifierTo(denoDir + specifier.substring(pkgName.length));
105-
} else if (specifier === 'qs') {
106-
decl.replaceWithText(`import { qs } from "https://deno.land/x/deno_qs@0.0.1/mod.ts"`);
107-
continue;
108105
} else if (!decl.isModuleSpecifierRelative()) {
109106
specifier = `npm:${specifier}`;
110107
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import * as Errors from './error';
44
import * as Uploads from './uploads';
55
import { type Agent } from './_shims/index';
6-
import * as qs from 'qs';
6+
import * as qs from './internal/qs';
77
import * as Core from './core';
88
import * as Pagination from './pagination';
99
import * as API from './resources/index';

src/internal/qs/LICENSE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2014, Nathan LaFreniere and other [contributors](https://github.com/puruvj/neoqs/graphs/contributors) All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8+
9+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10+
11+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12+
13+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

src/internal/qs/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# qs
2+
3+
This is a vendored version of [neoqs](https://github.com/PuruVJ/neoqs) which is a TypeScript rewrite of [qs](https://github.com/ljharb/qs), a query string library.

src/internal/qs/formats.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Format } from './types';
2+
3+
export const default_format: Format = 'RFC3986';
4+
export const formatters: Record<Format, (str: PropertyKey) => string> = {
5+
RFC1738: (v: PropertyKey) => String(v).replace(/%20/g, '+'),
6+
RFC3986: (v: PropertyKey) => String(v),
7+
};
8+
export const RFC1738 = 'RFC1738';
9+
export const RFC3986 = 'RFC3986';

src/internal/qs/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { default_format, formatters, RFC1738, RFC3986 } from './formats';
2+
3+
const formats = {
4+
formatters,
5+
RFC1738,
6+
RFC3986,
7+
default: default_format,
8+
};
9+
10+
export { stringify } from './stringify';
11+
export { formats };
12+
13+
export type { DefaultDecoder, DefaultEncoder, Format, ParseOptions, StringifyOptions } from './types';

0 commit comments

Comments
 (0)