@nocobase/plugin-multi-keyword-filter 2.0.3
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/LICENSE +201 -0
- package/README.md +99 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/0d9b6225e99c9b66.js +10 -0
- package/dist/client/MultipleKeywordsInput.d.ts +15 -0
- package/dist/client/index.d.ts +15 -0
- package/dist/client/index.js +10 -0
- package/dist/client/interceptor.d.ts +9 -0
- package/dist/client/locale.d.ts +10 -0
- package/dist/externalVersion.js +20 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/locale/de-DE.json +18 -0
- package/dist/locale/en-US.json +18 -0
- package/dist/locale/es-ES.json +18 -0
- package/dist/locale/fr-FR.json +18 -0
- package/dist/locale/hu-HU.json +18 -0
- package/dist/locale/id-ID.json +18 -0
- package/dist/locale/it-IT.json +18 -0
- package/dist/locale/ja-JP.json +18 -0
- package/dist/locale/ko-KR.json +18 -0
- package/dist/locale/nl-NL.json +18 -0
- package/dist/locale/pt-BR.json +18 -0
- package/dist/locale/ru-RU.json +18 -0
- package/dist/locale/tr-TR.json +18 -0
- package/dist/locale/uk-UA.json +18 -0
- package/dist/locale/vi-VN.json +18 -0
- package/dist/locale/zh-CN.json +18 -0
- package/dist/locale/zh-TW.json +18 -0
- package/dist/node_modules/qs/.editorconfig +43 -0
- package/dist/node_modules/qs/.eslintrc +38 -0
- package/dist/node_modules/qs/.github/FUNDING.yml +12 -0
- package/dist/node_modules/qs/.nycrc +13 -0
- package/dist/node_modules/qs/dist/qs.js +2087 -0
- package/dist/node_modules/qs/lib/formats.js +23 -0
- package/dist/node_modules/qs/lib/index.js +1 -0
- package/dist/node_modules/qs/lib/parse.js +264 -0
- package/dist/node_modules/qs/lib/stringify.js +320 -0
- package/dist/node_modules/qs/lib/utils.js +252 -0
- package/dist/node_modules/qs/package.json +1 -0
- package/dist/node_modules/qs/test/empty-keys-cases.js +37 -0
- package/dist/node_modules/qs/test/parse.js +898 -0
- package/dist/node_modules/qs/test/stringify.js +972 -0
- package/dist/node_modules/qs/test/utils.js +136 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +42 -0
- package/dist/server/middlewares.d.ts +10 -0
- package/dist/server/middlewares.js +63 -0
- package/dist/server/plugin.d.ts +19 -0
- package/dist/server/plugin.js +58 -0
- package/package.json +31 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var getSideChannel = require('side-channel');
|
|
4
|
+
var utils = require('./utils');
|
|
5
|
+
var formats = require('./formats');
|
|
6
|
+
var has = Object.prototype.hasOwnProperty;
|
|
7
|
+
|
|
8
|
+
var arrayPrefixGenerators = {
|
|
9
|
+
brackets: function brackets(prefix) {
|
|
10
|
+
return prefix + '[]';
|
|
11
|
+
},
|
|
12
|
+
comma: 'comma',
|
|
13
|
+
indices: function indices(prefix, key) {
|
|
14
|
+
return prefix + '[' + key + ']';
|
|
15
|
+
},
|
|
16
|
+
repeat: function repeat(prefix) {
|
|
17
|
+
return prefix;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var isArray = Array.isArray;
|
|
22
|
+
var push = Array.prototype.push;
|
|
23
|
+
var pushToArray = function (arr, valueOrArray) {
|
|
24
|
+
push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
var toISO = Date.prototype.toISOString;
|
|
28
|
+
|
|
29
|
+
var defaultFormat = formats['default'];
|
|
30
|
+
var defaults = {
|
|
31
|
+
addQueryPrefix: false,
|
|
32
|
+
allowDots: false,
|
|
33
|
+
charset: 'utf-8',
|
|
34
|
+
charsetSentinel: false,
|
|
35
|
+
delimiter: '&',
|
|
36
|
+
encode: true,
|
|
37
|
+
encoder: utils.encode,
|
|
38
|
+
encodeValuesOnly: false,
|
|
39
|
+
format: defaultFormat,
|
|
40
|
+
formatter: formats.formatters[defaultFormat],
|
|
41
|
+
// deprecated
|
|
42
|
+
indices: false,
|
|
43
|
+
serializeDate: function serializeDate(date) {
|
|
44
|
+
return toISO.call(date);
|
|
45
|
+
},
|
|
46
|
+
skipNulls: false,
|
|
47
|
+
strictNullHandling: false
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
|
|
51
|
+
return typeof v === 'string'
|
|
52
|
+
|| typeof v === 'number'
|
|
53
|
+
|| typeof v === 'boolean'
|
|
54
|
+
|| typeof v === 'symbol'
|
|
55
|
+
|| typeof v === 'bigint';
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var sentinel = {};
|
|
59
|
+
|
|
60
|
+
var stringify = function stringify(
|
|
61
|
+
object,
|
|
62
|
+
prefix,
|
|
63
|
+
generateArrayPrefix,
|
|
64
|
+
commaRoundTrip,
|
|
65
|
+
strictNullHandling,
|
|
66
|
+
skipNulls,
|
|
67
|
+
encoder,
|
|
68
|
+
filter,
|
|
69
|
+
sort,
|
|
70
|
+
allowDots,
|
|
71
|
+
serializeDate,
|
|
72
|
+
format,
|
|
73
|
+
formatter,
|
|
74
|
+
encodeValuesOnly,
|
|
75
|
+
charset,
|
|
76
|
+
sideChannel
|
|
77
|
+
) {
|
|
78
|
+
var obj = object;
|
|
79
|
+
|
|
80
|
+
var tmpSc = sideChannel;
|
|
81
|
+
var step = 0;
|
|
82
|
+
var findFlag = false;
|
|
83
|
+
while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) {
|
|
84
|
+
// Where object last appeared in the ref tree
|
|
85
|
+
var pos = tmpSc.get(object);
|
|
86
|
+
step += 1;
|
|
87
|
+
if (typeof pos !== 'undefined') {
|
|
88
|
+
if (pos === step) {
|
|
89
|
+
throw new RangeError('Cyclic object value');
|
|
90
|
+
} else {
|
|
91
|
+
findFlag = true; // Break while
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (typeof tmpSc.get(sentinel) === 'undefined') {
|
|
95
|
+
step = 0;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (typeof filter === 'function') {
|
|
100
|
+
obj = filter(prefix, obj);
|
|
101
|
+
} else if (obj instanceof Date) {
|
|
102
|
+
obj = serializeDate(obj);
|
|
103
|
+
} else if (generateArrayPrefix === 'comma' && isArray(obj)) {
|
|
104
|
+
obj = utils.maybeMap(obj, function (value) {
|
|
105
|
+
if (value instanceof Date) {
|
|
106
|
+
return serializeDate(value);
|
|
107
|
+
}
|
|
108
|
+
return value;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (obj === null) {
|
|
113
|
+
if (strictNullHandling) {
|
|
114
|
+
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
obj = '';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
|
|
121
|
+
if (encoder) {
|
|
122
|
+
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format);
|
|
123
|
+
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
|
|
124
|
+
}
|
|
125
|
+
return [formatter(prefix) + '=' + formatter(String(obj))];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
var values = [];
|
|
129
|
+
|
|
130
|
+
if (typeof obj === 'undefined') {
|
|
131
|
+
return values;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
var objKeys;
|
|
135
|
+
if (generateArrayPrefix === 'comma' && isArray(obj)) {
|
|
136
|
+
// we need to join elements in
|
|
137
|
+
if (encodeValuesOnly && encoder) {
|
|
138
|
+
obj = utils.maybeMap(obj, encoder);
|
|
139
|
+
}
|
|
140
|
+
objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];
|
|
141
|
+
} else if (isArray(filter)) {
|
|
142
|
+
objKeys = filter;
|
|
143
|
+
} else {
|
|
144
|
+
var keys = Object.keys(obj);
|
|
145
|
+
objKeys = sort ? keys.sort(sort) : keys;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? prefix + '[]' : prefix;
|
|
149
|
+
|
|
150
|
+
for (var j = 0; j < objKeys.length; ++j) {
|
|
151
|
+
var key = objKeys[j];
|
|
152
|
+
var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
|
|
153
|
+
|
|
154
|
+
if (skipNulls && value === null) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
var keyPrefix = isArray(obj)
|
|
159
|
+
? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix
|
|
160
|
+
: adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']');
|
|
161
|
+
|
|
162
|
+
sideChannel.set(object, step);
|
|
163
|
+
var valueSideChannel = getSideChannel();
|
|
164
|
+
valueSideChannel.set(sentinel, sideChannel);
|
|
165
|
+
pushToArray(values, stringify(
|
|
166
|
+
value,
|
|
167
|
+
keyPrefix,
|
|
168
|
+
generateArrayPrefix,
|
|
169
|
+
commaRoundTrip,
|
|
170
|
+
strictNullHandling,
|
|
171
|
+
skipNulls,
|
|
172
|
+
generateArrayPrefix === 'comma' && encodeValuesOnly && isArray(obj) ? null : encoder,
|
|
173
|
+
filter,
|
|
174
|
+
sort,
|
|
175
|
+
allowDots,
|
|
176
|
+
serializeDate,
|
|
177
|
+
format,
|
|
178
|
+
formatter,
|
|
179
|
+
encodeValuesOnly,
|
|
180
|
+
charset,
|
|
181
|
+
valueSideChannel
|
|
182
|
+
));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return values;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
|
|
189
|
+
if (!opts) {
|
|
190
|
+
return defaults;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
|
|
194
|
+
throw new TypeError('Encoder has to be a function.');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
var charset = opts.charset || defaults.charset;
|
|
198
|
+
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
|
199
|
+
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
var format = formats['default'];
|
|
203
|
+
if (typeof opts.format !== 'undefined') {
|
|
204
|
+
if (!has.call(formats.formatters, opts.format)) {
|
|
205
|
+
throw new TypeError('Unknown format option provided.');
|
|
206
|
+
}
|
|
207
|
+
format = opts.format;
|
|
208
|
+
}
|
|
209
|
+
var formatter = formats.formatters[format];
|
|
210
|
+
|
|
211
|
+
var filter = defaults.filter;
|
|
212
|
+
if (typeof opts.filter === 'function' || isArray(opts.filter)) {
|
|
213
|
+
filter = opts.filter;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
|
|
218
|
+
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
|
219
|
+
charset: charset,
|
|
220
|
+
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
|
|
221
|
+
delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
|
|
222
|
+
encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
|
|
223
|
+
encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
|
|
224
|
+
encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
|
|
225
|
+
filter: filter,
|
|
226
|
+
format: format,
|
|
227
|
+
formatter: formatter,
|
|
228
|
+
serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,
|
|
229
|
+
skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,
|
|
230
|
+
sort: typeof opts.sort === 'function' ? opts.sort : null,
|
|
231
|
+
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
module.exports = function (object, opts) {
|
|
236
|
+
var obj = object;
|
|
237
|
+
var options = normalizeStringifyOptions(opts);
|
|
238
|
+
|
|
239
|
+
var objKeys;
|
|
240
|
+
var filter;
|
|
241
|
+
|
|
242
|
+
if (typeof options.filter === 'function') {
|
|
243
|
+
filter = options.filter;
|
|
244
|
+
obj = filter('', obj);
|
|
245
|
+
} else if (isArray(options.filter)) {
|
|
246
|
+
filter = options.filter;
|
|
247
|
+
objKeys = filter;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
var keys = [];
|
|
251
|
+
|
|
252
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
253
|
+
return '';
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
var arrayFormat;
|
|
257
|
+
if (opts && opts.arrayFormat in arrayPrefixGenerators) {
|
|
258
|
+
arrayFormat = opts.arrayFormat;
|
|
259
|
+
} else if (opts && 'indices' in opts) {
|
|
260
|
+
arrayFormat = opts.indices ? 'indices' : 'repeat';
|
|
261
|
+
} else {
|
|
262
|
+
arrayFormat = 'indices';
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
|
|
266
|
+
if (opts && 'commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
|
|
267
|
+
throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
|
|
268
|
+
}
|
|
269
|
+
var commaRoundTrip = generateArrayPrefix === 'comma' && opts && opts.commaRoundTrip;
|
|
270
|
+
|
|
271
|
+
if (!objKeys) {
|
|
272
|
+
objKeys = Object.keys(obj);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (options.sort) {
|
|
276
|
+
objKeys.sort(options.sort);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
var sideChannel = getSideChannel();
|
|
280
|
+
for (var i = 0; i < objKeys.length; ++i) {
|
|
281
|
+
var key = objKeys[i];
|
|
282
|
+
|
|
283
|
+
if (options.skipNulls && obj[key] === null) {
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
pushToArray(keys, stringify(
|
|
287
|
+
obj[key],
|
|
288
|
+
key,
|
|
289
|
+
generateArrayPrefix,
|
|
290
|
+
commaRoundTrip,
|
|
291
|
+
options.strictNullHandling,
|
|
292
|
+
options.skipNulls,
|
|
293
|
+
options.encode ? options.encoder : null,
|
|
294
|
+
options.filter,
|
|
295
|
+
options.sort,
|
|
296
|
+
options.allowDots,
|
|
297
|
+
options.serializeDate,
|
|
298
|
+
options.format,
|
|
299
|
+
options.formatter,
|
|
300
|
+
options.encodeValuesOnly,
|
|
301
|
+
options.charset,
|
|
302
|
+
sideChannel
|
|
303
|
+
));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
var joined = keys.join(options.delimiter);
|
|
307
|
+
var prefix = options.addQueryPrefix === true ? '?' : '';
|
|
308
|
+
|
|
309
|
+
if (options.charsetSentinel) {
|
|
310
|
+
if (options.charset === 'iso-8859-1') {
|
|
311
|
+
// encodeURIComponent('✓'), the "numeric entity" representation of a checkmark
|
|
312
|
+
prefix += 'utf8=%26%2310003%3B&';
|
|
313
|
+
} else {
|
|
314
|
+
// encodeURIComponent('✓')
|
|
315
|
+
prefix += 'utf8=%E2%9C%93&';
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return joined.length > 0 ? prefix + joined : '';
|
|
320
|
+
};
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var formats = require('./formats');
|
|
4
|
+
|
|
5
|
+
var has = Object.prototype.hasOwnProperty;
|
|
6
|
+
var isArray = Array.isArray;
|
|
7
|
+
|
|
8
|
+
var hexTable = (function () {
|
|
9
|
+
var array = [];
|
|
10
|
+
for (var i = 0; i < 256; ++i) {
|
|
11
|
+
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return array;
|
|
15
|
+
}());
|
|
16
|
+
|
|
17
|
+
var compactQueue = function compactQueue(queue) {
|
|
18
|
+
while (queue.length > 1) {
|
|
19
|
+
var item = queue.pop();
|
|
20
|
+
var obj = item.obj[item.prop];
|
|
21
|
+
|
|
22
|
+
if (isArray(obj)) {
|
|
23
|
+
var compacted = [];
|
|
24
|
+
|
|
25
|
+
for (var j = 0; j < obj.length; ++j) {
|
|
26
|
+
if (typeof obj[j] !== 'undefined') {
|
|
27
|
+
compacted.push(obj[j]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
item.obj[item.prop] = compacted;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var arrayToObject = function arrayToObject(source, options) {
|
|
37
|
+
var obj = options && options.plainObjects ? Object.create(null) : {};
|
|
38
|
+
for (var i = 0; i < source.length; ++i) {
|
|
39
|
+
if (typeof source[i] !== 'undefined') {
|
|
40
|
+
obj[i] = source[i];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return obj;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
var merge = function merge(target, source, options) {
|
|
48
|
+
/* eslint no-param-reassign: 0 */
|
|
49
|
+
if (!source) {
|
|
50
|
+
return target;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (typeof source !== 'object') {
|
|
54
|
+
if (isArray(target)) {
|
|
55
|
+
target.push(source);
|
|
56
|
+
} else if (target && typeof target === 'object') {
|
|
57
|
+
if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
|
|
58
|
+
target[source] = true;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
return [target, source];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return target;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!target || typeof target !== 'object') {
|
|
68
|
+
return [target].concat(source);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
var mergeTarget = target;
|
|
72
|
+
if (isArray(target) && !isArray(source)) {
|
|
73
|
+
mergeTarget = arrayToObject(target, options);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (isArray(target) && isArray(source)) {
|
|
77
|
+
source.forEach(function (item, i) {
|
|
78
|
+
if (has.call(target, i)) {
|
|
79
|
+
var targetItem = target[i];
|
|
80
|
+
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
81
|
+
target[i] = merge(targetItem, item, options);
|
|
82
|
+
} else {
|
|
83
|
+
target.push(item);
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
target[i] = item;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return target;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
93
|
+
var value = source[key];
|
|
94
|
+
|
|
95
|
+
if (has.call(acc, key)) {
|
|
96
|
+
acc[key] = merge(acc[key], value, options);
|
|
97
|
+
} else {
|
|
98
|
+
acc[key] = value;
|
|
99
|
+
}
|
|
100
|
+
return acc;
|
|
101
|
+
}, mergeTarget);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
var assign = function assignSingleSource(target, source) {
|
|
105
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
106
|
+
acc[key] = source[key];
|
|
107
|
+
return acc;
|
|
108
|
+
}, target);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
var decode = function (str, decoder, charset) {
|
|
112
|
+
var strWithoutPlus = str.replace(/\+/g, ' ');
|
|
113
|
+
if (charset === 'iso-8859-1') {
|
|
114
|
+
// unescape never throws, no try...catch needed:
|
|
115
|
+
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
|
116
|
+
}
|
|
117
|
+
// utf-8
|
|
118
|
+
try {
|
|
119
|
+
return decodeURIComponent(strWithoutPlus);
|
|
120
|
+
} catch (e) {
|
|
121
|
+
return strWithoutPlus;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
var encode = function encode(str, defaultEncoder, charset, kind, format) {
|
|
126
|
+
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
|
|
127
|
+
// It has been adapted here for stricter adherence to RFC 3986
|
|
128
|
+
if (str.length === 0) {
|
|
129
|
+
return str;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
var string = str;
|
|
133
|
+
if (typeof str === 'symbol') {
|
|
134
|
+
string = Symbol.prototype.toString.call(str);
|
|
135
|
+
} else if (typeof str !== 'string') {
|
|
136
|
+
string = String(str);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (charset === 'iso-8859-1') {
|
|
140
|
+
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
|
141
|
+
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
var out = '';
|
|
146
|
+
for (var i = 0; i < string.length; ++i) {
|
|
147
|
+
var c = string.charCodeAt(i);
|
|
148
|
+
|
|
149
|
+
if (
|
|
150
|
+
c === 0x2D // -
|
|
151
|
+
|| c === 0x2E // .
|
|
152
|
+
|| c === 0x5F // _
|
|
153
|
+
|| c === 0x7E // ~
|
|
154
|
+
|| (c >= 0x30 && c <= 0x39) // 0-9
|
|
155
|
+
|| (c >= 0x41 && c <= 0x5A) // a-z
|
|
156
|
+
|| (c >= 0x61 && c <= 0x7A) // A-Z
|
|
157
|
+
|| (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
|
|
158
|
+
) {
|
|
159
|
+
out += string.charAt(i);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (c < 0x80) {
|
|
164
|
+
out = out + hexTable[c];
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (c < 0x800) {
|
|
169
|
+
out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (c < 0xD800 || c >= 0xE000) {
|
|
174
|
+
out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
i += 1;
|
|
179
|
+
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
|
|
180
|
+
/* eslint operator-linebreak: [2, "before"] */
|
|
181
|
+
out += hexTable[0xF0 | (c >> 18)]
|
|
182
|
+
+ hexTable[0x80 | ((c >> 12) & 0x3F)]
|
|
183
|
+
+ hexTable[0x80 | ((c >> 6) & 0x3F)]
|
|
184
|
+
+ hexTable[0x80 | (c & 0x3F)];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return out;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
var compact = function compact(value) {
|
|
191
|
+
var queue = [{ obj: { o: value }, prop: 'o' }];
|
|
192
|
+
var refs = [];
|
|
193
|
+
|
|
194
|
+
for (var i = 0; i < queue.length; ++i) {
|
|
195
|
+
var item = queue[i];
|
|
196
|
+
var obj = item.obj[item.prop];
|
|
197
|
+
|
|
198
|
+
var keys = Object.keys(obj);
|
|
199
|
+
for (var j = 0; j < keys.length; ++j) {
|
|
200
|
+
var key = keys[j];
|
|
201
|
+
var val = obj[key];
|
|
202
|
+
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
203
|
+
queue.push({ obj: obj, prop: key });
|
|
204
|
+
refs.push(val);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
compactQueue(queue);
|
|
210
|
+
|
|
211
|
+
return value;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
var isRegExp = function isRegExp(obj) {
|
|
215
|
+
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
var isBuffer = function isBuffer(obj) {
|
|
219
|
+
if (!obj || typeof obj !== 'object') {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
var combine = function combine(a, b) {
|
|
227
|
+
return [].concat(a, b);
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
var maybeMap = function maybeMap(val, fn) {
|
|
231
|
+
if (isArray(val)) {
|
|
232
|
+
var mapped = [];
|
|
233
|
+
for (var i = 0; i < val.length; i += 1) {
|
|
234
|
+
mapped.push(fn(val[i]));
|
|
235
|
+
}
|
|
236
|
+
return mapped;
|
|
237
|
+
}
|
|
238
|
+
return fn(val);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
module.exports = {
|
|
242
|
+
arrayToObject: arrayToObject,
|
|
243
|
+
assign: assign,
|
|
244
|
+
combine: combine,
|
|
245
|
+
compact: compact,
|
|
246
|
+
decode: decode,
|
|
247
|
+
encode: encode,
|
|
248
|
+
isBuffer: isBuffer,
|
|
249
|
+
isRegExp: isRegExp,
|
|
250
|
+
maybeMap: maybeMap,
|
|
251
|
+
merge: merge
|
|
252
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"qs","description":"A querystring parser that supports nesting and arrays, with a depth limit","homepage":"https://github.com/ljharb/qs","version":"6.11.2","repository":{"type":"git","url":"https://github.com/ljharb/qs.git"},"funding":{"url":"https://github.com/sponsors/ljharb"},"main":"lib/index.js","contributors":[{"name":"Jordan Harband","email":"ljharb@gmail.com","url":"http://ljharb.codes"}],"keywords":["querystring","qs","query","url","parse","stringify"],"engines":{"node":">=0.6"},"dependencies":{"side-channel":"^1.0.4"},"devDependencies":{"@ljharb/eslint-config":"^21.0.1","aud":"^2.0.2","browserify":"^16.5.2","eclint":"^2.8.1","eslint":"=8.8.0","evalmd":"^0.0.19","for-each":"^0.3.3","has-override-mistake":"^1.0.0","has-property-descriptors":"^1.0.0","has-symbols":"^1.0.3","iconv-lite":"^0.5.1","in-publish":"^2.0.1","mkdirp":"^0.5.5","mock-property":"^1.0.0","npmignore":"^0.3.0","nyc":"^10.3.2","object-inspect":"^1.12.3","qs-iconv":"^1.0.4","safe-publish-latest":"^2.0.0","safer-buffer":"^2.1.2","tape":"^5.6.3"},"scripts":{"prepack":"npmignore --auto --commentLines=autogenerated","prepublishOnly":"safe-publish-latest && npm run dist","prepublish":"not-in-publish || npm run prepublishOnly","pretest":"npm run --silent readme && npm run --silent lint","test":"npm run tests-only","tests-only":"nyc tape 'test/**/*.js'","posttest":"aud --production","readme":"evalmd README.md","postlint":"eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git' | grep -v dist/)","lint":"eslint --ext=js,mjs .","dist":"mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js"},"license":"BSD-3-Clause","publishConfig":{"ignore":["!dist/*","bower.json","component.json",".github/workflows"]},"_lastModified":"2026-02-24T16:59:57.449Z"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
emptyTestCases: [
|
|
5
|
+
{ input: '&', withEmptyKeys: {}, stringifyOutput: '', noEmptyKeys: {} },
|
|
6
|
+
{ input: '&&', withEmptyKeys: {}, stringifyOutput: '', noEmptyKeys: {} },
|
|
7
|
+
{ input: '&=', withEmptyKeys: { '': '' }, stringifyOutput: '=', noEmptyKeys: {} },
|
|
8
|
+
{ input: '&=&', withEmptyKeys: { '': '' }, stringifyOutput: '=', noEmptyKeys: {} },
|
|
9
|
+
{ input: '&=&=', withEmptyKeys: { '': ['', ''] }, stringifyOutput: '[0]=&[1]=', noEmptyKeys: {} },
|
|
10
|
+
{ input: '&=&=&', withEmptyKeys: { '': ['', ''] }, stringifyOutput: '[0]=&[1]=', noEmptyKeys: {} },
|
|
11
|
+
|
|
12
|
+
{ input: '=', withEmptyKeys: { '': '' }, noEmptyKeys: {}, stringifyOutput: '=' },
|
|
13
|
+
{ input: '=&', withEmptyKeys: { '': '' }, stringifyOutput: '=', noEmptyKeys: {} },
|
|
14
|
+
{ input: '=&&&', withEmptyKeys: { '': '' }, stringifyOutput: '=', noEmptyKeys: {} },
|
|
15
|
+
{ input: '=&=&=&', withEmptyKeys: { '': ['', '', ''] }, stringifyOutput: '[0]=&[1]=&[2]=', noEmptyKeys: {} },
|
|
16
|
+
{ input: '=&a[]=b&a[1]=c', withEmptyKeys: { '': '', a: ['b', 'c'] }, stringifyOutput: '=&a[0]=b&a[1]=c', noEmptyKeys: { a: ['b', 'c'] } },
|
|
17
|
+
{ input: '=a', withEmptyKeys: { '': 'a' }, noEmptyKeys: {}, stringifyOutput: '=a' },
|
|
18
|
+
{ input: '=a', withEmptyKeys: { '': 'a' }, noEmptyKeys: {}, stringifyOutput: '=a' },
|
|
19
|
+
{ input: 'a==a', withEmptyKeys: { a: '=a' }, noEmptyKeys: { a: '=a' }, stringifyOutput: 'a==a' },
|
|
20
|
+
|
|
21
|
+
{ input: '=&a[]=b', withEmptyKeys: { '': '', a: ['b'] }, stringifyOutput: '=&a[0]=b', noEmptyKeys: { a: ['b'] } },
|
|
22
|
+
{ input: '=&a[]=b&a[]=c&a[2]=d', withEmptyKeys: { '': '', a: ['b', 'c', 'd'] }, stringifyOutput: '=&a[0]=b&a[1]=c&a[2]=d', noEmptyKeys: { a: ['b', 'c', 'd'] } },
|
|
23
|
+
{ input: '=a&=b', withEmptyKeys: { '': ['a', 'b'] }, stringifyOutput: '[0]=a&[1]=b', noEmptyKeys: {} },
|
|
24
|
+
{ input: '=a&foo=b', withEmptyKeys: { '': 'a', foo: 'b' }, noEmptyKeys: { foo: 'b' }, stringifyOutput: '=a&foo=b' },
|
|
25
|
+
|
|
26
|
+
{ input: 'a[]=b&a=c&=', withEmptyKeys: { '': '', a: ['b', 'c'] }, stringifyOutput: '=&a[0]=b&a[1]=c', noEmptyKeys: { a: ['b', 'c'] } },
|
|
27
|
+
{ input: 'a[]=b&a=c&=', withEmptyKeys: { '': '', a: ['b', 'c'] }, stringifyOutput: '=&a[0]=b&a[1]=c', noEmptyKeys: { a: ['b', 'c'] } },
|
|
28
|
+
{ input: 'a[0]=b&a=c&=', withEmptyKeys: { '': '', a: ['b', 'c'] }, stringifyOutput: '=&a[0]=b&a[1]=c', noEmptyKeys: { a: ['b', 'c'] } },
|
|
29
|
+
{ input: 'a=b&a[]=c&=', withEmptyKeys: { '': '', a: ['b', 'c'] }, stringifyOutput: '=&a[0]=b&a[1]=c', noEmptyKeys: { a: ['b', 'c'] } },
|
|
30
|
+
{ input: 'a=b&a[0]=c&=', withEmptyKeys: { '': '', a: ['b', 'c'] }, stringifyOutput: '=&a[0]=b&a[1]=c', noEmptyKeys: { a: ['b', 'c'] } },
|
|
31
|
+
|
|
32
|
+
{ input: '[]=a&[]=b& []=1', withEmptyKeys: { '': ['a', 'b'], ' ': ['1'] }, stringifyOutput: '[0]=a&[1]=b& [0]=1', noEmptyKeys: { 0: 'a', 1: 'b', ' ': ['1'] } },
|
|
33
|
+
{ input: '[0]=a&[1]=b&a[0]=1&a[1]=2', withEmptyKeys: { '': ['a', 'b'], a: ['1', '2'] }, noEmptyKeys: { 0: 'a', 1: 'b', a: ['1', '2'] }, stringifyOutput: '[0]=a&[1]=b&a[0]=1&a[1]=2' },
|
|
34
|
+
{ input: '[deep]=a&[deep]=2', withEmptyKeys: { '': { deep: ['a', '2'] } }, stringifyOutput: '[deep][0]=a&[deep][1]=2', noEmptyKeys: { deep: ['a', '2'] } },
|
|
35
|
+
{ input: '%5B0%5D=a&%5B1%5D=b', withEmptyKeys: { '': ['a', 'b'] }, stringifyOutput: '[0]=a&[1]=b', noEmptyKeys: { 0: 'a', 1: 'b' } }
|
|
36
|
+
]
|
|
37
|
+
};
|