Skip to content

Commit e96702f

Browse files
authored
feat: switch buffer to native Uint8Array (#2288)
During this effort querystring-browser library was replaced by native UrlSearchParams. Refs #2243
1 parent 3af9b24 commit e96702f

File tree

4 files changed

+7
-34
lines changed

4 files changed

+7
-34
lines changed

package-lock.json

Lines changed: 0 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@
109109
"dependencies": {
110110
"@babel/runtime-corejs3": "^7.11.2",
111111
"btoa": "^1.2.1",
112-
"buffer": "^6.0.3",
113112
"cookie": "~0.4.1",
114113
"cross-fetch": "^3.1.4",
115114
"deep-extend": "~0.6.0",
@@ -119,7 +118,6 @@
119118
"js-yaml": "^4.1.0",
120119
"lodash": "^4.17.21",
121120
"qs": "^6.9.4",
122-
"querystring-browser": "^1.0.4",
123121
"traverse": "~0.6.6",
124122
"url": "~0.11.0"
125123
}

src/execute/oas3/style-serializer.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const { Buffer } = require('buffer');
2-
31
const isRfc3986Reserved = (char) => ":/?#[]@!$&'()*+,;=".indexOf(char) > -1;
42
const isRrc3986Unreserved = (char) => /^[a-z0-9\-._~]+$/i.test(char);
53

@@ -33,7 +31,8 @@ export function encodeDisallowedCharacters(str, { escape } = {}, parse) {
3331
return char;
3432
}
3533

36-
const encoded = (Buffer.from(char).toJSON().data || [])
34+
const encoder = new TextEncoder();
35+
const encoded = Array.from(encoder.encode(char))
3736
.map((byte) => `0${byte.toString(16).toUpperCase()}`.slice(-2))
3837
.map((encodedByte) => `%${encodedByte}`)
3938
.join('');

src/specmap/lib/refs.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'cross-fetch/polyfill'; /* global fetch */
22
import jsYaml from 'js-yaml';
3-
import qs from 'querystring-browser';
43
import url from 'url';
54

65
import lib from '.';
@@ -432,15 +431,18 @@ function unescapeJsonPointerToken(token) {
432431
if (typeof token !== 'string') {
433432
return token;
434433
}
435-
return qs.unescape(token.replace(/~1/g, '/').replace(/~0/g, '~'));
434+
435+
const params = new URLSearchParams(`=${token.replace(/~1/g, '/').replace(/~0/g, '~')}`);
436+
return params.get('');
436437
}
437438

438439
/**
439440
* Escapes a JSON pointer.
440441
* @api public
441442
*/
442443
function escapeJsonPointerToken(token) {
443-
return qs.escape(token.replace(/~/g, '~0').replace(/\//g, '~1'));
444+
const params = new URLSearchParams([['', token.replace(/~/g, '~0').replace(/\//g, '~1')]]);
445+
return params.toString().slice(1);
444446
}
445447

446448
function arrayToJsonPointer(arr) {

0 commit comments

Comments
 (0)