@tryghost/content-api 1.12.2 → 1.12.4
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 +1 -1
- package/README.md +1 -1
- package/cjs/content-api.js +17 -15
- package/es/content-api.js +368 -296
- package/es/content-api.js.map +1 -1
- package/package.json +15 -15
- package/umd/content-api.min.js +1 -1
- package/umd/content-api.min.js.map +1 -1
package/es/content-api.js
CHANGED
|
@@ -13,30 +13,30 @@ function bind(fn, thisArg) {
|
|
|
13
13
|
|
|
14
14
|
// utils is a library of generic helper functions non-specific to axios
|
|
15
15
|
|
|
16
|
-
const {toString} = Object.prototype;
|
|
17
|
-
const {getPrototypeOf} = Object;
|
|
18
|
-
const {iterator, toStringTag} = Symbol;
|
|
16
|
+
const { toString } = Object.prototype;
|
|
17
|
+
const { getPrototypeOf } = Object;
|
|
18
|
+
const { iterator, toStringTag } = Symbol;
|
|
19
19
|
|
|
20
|
-
const kindOf = (cache => thing => {
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const kindOf = ((cache) => (thing) => {
|
|
21
|
+
const str = toString.call(thing);
|
|
22
|
+
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
23
23
|
})(Object.create(null));
|
|
24
24
|
|
|
25
25
|
const kindOfTest = (type) => {
|
|
26
26
|
type = type.toLowerCase();
|
|
27
|
-
return (thing) => kindOf(thing) === type
|
|
27
|
+
return (thing) => kindOf(thing) === type;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
const typeOfTest = type => thing => typeof thing === type;
|
|
30
|
+
const typeOfTest = (type) => (thing) => typeof thing === type;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* Determine if a value is
|
|
33
|
+
* Determine if a value is a non-null object
|
|
34
34
|
*
|
|
35
35
|
* @param {Object} val The value to test
|
|
36
36
|
*
|
|
37
37
|
* @returns {boolean} True if value is an Array, otherwise false
|
|
38
38
|
*/
|
|
39
|
-
const {isArray} = Array;
|
|
39
|
+
const { isArray } = Array;
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Determine if a value is undefined
|
|
@@ -45,7 +45,7 @@ const {isArray} = Array;
|
|
|
45
45
|
*
|
|
46
46
|
* @returns {boolean} True if the value is undefined, otherwise false
|
|
47
47
|
*/
|
|
48
|
-
const isUndefined = typeOfTest(
|
|
48
|
+
const isUndefined = typeOfTest("undefined");
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Determine if a value is a Buffer
|
|
@@ -55,8 +55,14 @@ const isUndefined = typeOfTest('undefined');
|
|
|
55
55
|
* @returns {boolean} True if value is a Buffer, otherwise false
|
|
56
56
|
*/
|
|
57
57
|
function isBuffer(val) {
|
|
58
|
-
return
|
|
59
|
-
|
|
58
|
+
return (
|
|
59
|
+
val !== null &&
|
|
60
|
+
!isUndefined(val) &&
|
|
61
|
+
val.constructor !== null &&
|
|
62
|
+
!isUndefined(val.constructor) &&
|
|
63
|
+
isFunction$1(val.constructor.isBuffer) &&
|
|
64
|
+
val.constructor.isBuffer(val)
|
|
65
|
+
);
|
|
60
66
|
}
|
|
61
67
|
|
|
62
68
|
/**
|
|
@@ -66,8 +72,7 @@ function isBuffer(val) {
|
|
|
66
72
|
*
|
|
67
73
|
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
68
74
|
*/
|
|
69
|
-
const isArrayBuffer = kindOfTest(
|
|
70
|
-
|
|
75
|
+
const isArrayBuffer = kindOfTest("ArrayBuffer");
|
|
71
76
|
|
|
72
77
|
/**
|
|
73
78
|
* Determine if a value is a view on an ArrayBuffer
|
|
@@ -78,10 +83,10 @@ const isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
|
78
83
|
*/
|
|
79
84
|
function isArrayBufferView(val) {
|
|
80
85
|
let result;
|
|
81
|
-
if (
|
|
86
|
+
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
|
|
82
87
|
result = ArrayBuffer.isView(val);
|
|
83
88
|
} else {
|
|
84
|
-
result =
|
|
89
|
+
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
85
90
|
}
|
|
86
91
|
return result;
|
|
87
92
|
}
|
|
@@ -93,7 +98,7 @@ function isArrayBufferView(val) {
|
|
|
93
98
|
*
|
|
94
99
|
* @returns {boolean} True if value is a String, otherwise false
|
|
95
100
|
*/
|
|
96
|
-
const isString = typeOfTest(
|
|
101
|
+
const isString = typeOfTest("string");
|
|
97
102
|
|
|
98
103
|
/**
|
|
99
104
|
* Determine if a value is a Function
|
|
@@ -101,7 +106,7 @@ const isString = typeOfTest('string');
|
|
|
101
106
|
* @param {*} val The value to test
|
|
102
107
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
103
108
|
*/
|
|
104
|
-
const isFunction$1 = typeOfTest(
|
|
109
|
+
const isFunction$1 = typeOfTest("function");
|
|
105
110
|
|
|
106
111
|
/**
|
|
107
112
|
* Determine if a value is a Number
|
|
@@ -110,7 +115,7 @@ const isFunction$1 = typeOfTest('function');
|
|
|
110
115
|
*
|
|
111
116
|
* @returns {boolean} True if value is a Number, otherwise false
|
|
112
117
|
*/
|
|
113
|
-
const isNumber = typeOfTest(
|
|
118
|
+
const isNumber = typeOfTest("number");
|
|
114
119
|
|
|
115
120
|
/**
|
|
116
121
|
* Determine if a value is an Object
|
|
@@ -119,7 +124,7 @@ const isNumber = typeOfTest('number');
|
|
|
119
124
|
*
|
|
120
125
|
* @returns {boolean} True if value is an Object, otherwise false
|
|
121
126
|
*/
|
|
122
|
-
const isObject = (thing) => thing !== null && typeof thing ===
|
|
127
|
+
const isObject = (thing) => thing !== null && typeof thing === "object";
|
|
123
128
|
|
|
124
129
|
/**
|
|
125
130
|
* Determine if a value is a Boolean
|
|
@@ -127,7 +132,7 @@ const isObject = (thing) => thing !== null && typeof thing === 'object';
|
|
|
127
132
|
* @param {*} thing The value to test
|
|
128
133
|
* @returns {boolean} True if value is a Boolean, otherwise false
|
|
129
134
|
*/
|
|
130
|
-
const isBoolean = thing => thing === true || thing === false;
|
|
135
|
+
const isBoolean = (thing) => thing === true || thing === false;
|
|
131
136
|
|
|
132
137
|
/**
|
|
133
138
|
* Determine if a value is a plain Object
|
|
@@ -137,12 +142,18 @@ const isBoolean = thing => thing === true || thing === false;
|
|
|
137
142
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
138
143
|
*/
|
|
139
144
|
const isPlainObject = (val) => {
|
|
140
|
-
if (kindOf(val) !==
|
|
145
|
+
if (kindOf(val) !== "object") {
|
|
141
146
|
return false;
|
|
142
147
|
}
|
|
143
148
|
|
|
144
149
|
const prototype = getPrototypeOf(val);
|
|
145
|
-
return (
|
|
150
|
+
return (
|
|
151
|
+
(prototype === null ||
|
|
152
|
+
prototype === Object.prototype ||
|
|
153
|
+
Object.getPrototypeOf(prototype) === null) &&
|
|
154
|
+
!(toStringTag in val) &&
|
|
155
|
+
!(iterator in val)
|
|
156
|
+
);
|
|
146
157
|
};
|
|
147
158
|
|
|
148
159
|
/**
|
|
@@ -159,7 +170,10 @@ const isEmptyObject = (val) => {
|
|
|
159
170
|
}
|
|
160
171
|
|
|
161
172
|
try {
|
|
162
|
-
return
|
|
173
|
+
return (
|
|
174
|
+
Object.keys(val).length === 0 &&
|
|
175
|
+
Object.getPrototypeOf(val) === Object.prototype
|
|
176
|
+
);
|
|
163
177
|
} catch (e) {
|
|
164
178
|
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
165
179
|
return false;
|
|
@@ -173,7 +187,7 @@ const isEmptyObject = (val) => {
|
|
|
173
187
|
*
|
|
174
188
|
* @returns {boolean} True if value is a Date, otherwise false
|
|
175
189
|
*/
|
|
176
|
-
const isDate = kindOfTest(
|
|
190
|
+
const isDate = kindOfTest("Date");
|
|
177
191
|
|
|
178
192
|
/**
|
|
179
193
|
* Determine if a value is a File
|
|
@@ -182,7 +196,7 @@ const isDate = kindOfTest('Date');
|
|
|
182
196
|
*
|
|
183
197
|
* @returns {boolean} True if value is a File, otherwise false
|
|
184
198
|
*/
|
|
185
|
-
const isFile = kindOfTest(
|
|
199
|
+
const isFile = kindOfTest("File");
|
|
186
200
|
|
|
187
201
|
/**
|
|
188
202
|
* Determine if a value is a Blob
|
|
@@ -191,7 +205,7 @@ const isFile = kindOfTest('File');
|
|
|
191
205
|
*
|
|
192
206
|
* @returns {boolean} True if value is a Blob, otherwise false
|
|
193
207
|
*/
|
|
194
|
-
const isBlob = kindOfTest(
|
|
208
|
+
const isBlob = kindOfTest("Blob");
|
|
195
209
|
|
|
196
210
|
/**
|
|
197
211
|
* Determine if a value is a FileList
|
|
@@ -200,7 +214,7 @@ const isBlob = kindOfTest('Blob');
|
|
|
200
214
|
*
|
|
201
215
|
* @returns {boolean} True if value is a File, otherwise false
|
|
202
216
|
*/
|
|
203
|
-
const isFileList = kindOfTest(
|
|
217
|
+
const isFileList = kindOfTest("FileList");
|
|
204
218
|
|
|
205
219
|
/**
|
|
206
220
|
* Determine if a value is a Stream
|
|
@@ -220,15 +234,16 @@ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
|
220
234
|
*/
|
|
221
235
|
const isFormData = (thing) => {
|
|
222
236
|
let kind;
|
|
223
|
-
return
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
237
|
+
return (
|
|
238
|
+
thing &&
|
|
239
|
+
((typeof FormData === "function" && thing instanceof FormData) ||
|
|
240
|
+
(isFunction$1(thing.append) &&
|
|
241
|
+
((kind = kindOf(thing)) === "formdata" ||
|
|
242
|
+
// detect form-data instance
|
|
243
|
+
(kind === "object" &&
|
|
244
|
+
isFunction$1(thing.toString) &&
|
|
245
|
+
thing.toString() === "[object FormData]"))))
|
|
246
|
+
);
|
|
232
247
|
};
|
|
233
248
|
|
|
234
249
|
/**
|
|
@@ -238,9 +253,14 @@ const isFormData = (thing) => {
|
|
|
238
253
|
*
|
|
239
254
|
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
240
255
|
*/
|
|
241
|
-
const isURLSearchParams = kindOfTest(
|
|
256
|
+
const isURLSearchParams = kindOfTest("URLSearchParams");
|
|
242
257
|
|
|
243
|
-
const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
258
|
+
const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
259
|
+
"ReadableStream",
|
|
260
|
+
"Request",
|
|
261
|
+
"Response",
|
|
262
|
+
"Headers",
|
|
263
|
+
].map(kindOfTest);
|
|
244
264
|
|
|
245
265
|
/**
|
|
246
266
|
* Trim excess whitespace off the beginning and end of a string
|
|
@@ -249,8 +269,8 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream',
|
|
|
249
269
|
*
|
|
250
270
|
* @returns {String} The String freed of excess whitespace
|
|
251
271
|
*/
|
|
252
|
-
const trim = (str) =>
|
|
253
|
-
str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
|
|
272
|
+
const trim = (str) =>
|
|
273
|
+
str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
254
274
|
|
|
255
275
|
/**
|
|
256
276
|
* Iterate over an Array or an Object invoking a function for each item.
|
|
@@ -261,15 +281,16 @@ const trim = (str) => str.trim ?
|
|
|
261
281
|
* If 'obj' is an Object callback will be called passing
|
|
262
282
|
* the value, key, and complete object for each property.
|
|
263
283
|
*
|
|
264
|
-
* @param {Object|Array} obj The object to iterate
|
|
284
|
+
* @param {Object|Array<unknown>} obj The object to iterate
|
|
265
285
|
* @param {Function} fn The callback to invoke for each item
|
|
266
286
|
*
|
|
267
|
-
* @param {
|
|
287
|
+
* @param {Object} [options]
|
|
288
|
+
* @param {Boolean} [options.allOwnKeys = false]
|
|
268
289
|
* @returns {any}
|
|
269
290
|
*/
|
|
270
|
-
function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
291
|
+
function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
271
292
|
// Don't bother if no value provided
|
|
272
|
-
if (obj === null || typeof obj ===
|
|
293
|
+
if (obj === null || typeof obj === "undefined") {
|
|
273
294
|
return;
|
|
274
295
|
}
|
|
275
296
|
|
|
@@ -277,7 +298,7 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
277
298
|
let l;
|
|
278
299
|
|
|
279
300
|
// Force an array if not already something iterable
|
|
280
|
-
if (typeof obj !==
|
|
301
|
+
if (typeof obj !== "object") {
|
|
281
302
|
/*eslint no-param-reassign:0*/
|
|
282
303
|
obj = [obj];
|
|
283
304
|
}
|
|
@@ -294,7 +315,9 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
294
315
|
}
|
|
295
316
|
|
|
296
317
|
// Iterate over object keys
|
|
297
|
-
const keys = allOwnKeys
|
|
318
|
+
const keys = allOwnKeys
|
|
319
|
+
? Object.getOwnPropertyNames(obj)
|
|
320
|
+
: Object.keys(obj);
|
|
298
321
|
const len = keys.length;
|
|
299
322
|
let key;
|
|
300
323
|
|
|
@@ -306,7 +329,7 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
306
329
|
}
|
|
307
330
|
|
|
308
331
|
function findKey(obj, key) {
|
|
309
|
-
if (isBuffer(obj)){
|
|
332
|
+
if (isBuffer(obj)) {
|
|
310
333
|
return null;
|
|
311
334
|
}
|
|
312
335
|
|
|
@@ -326,10 +349,15 @@ function findKey(obj, key) {
|
|
|
326
349
|
const _global = (() => {
|
|
327
350
|
/*eslint no-undef:0*/
|
|
328
351
|
if (typeof globalThis !== "undefined") return globalThis;
|
|
329
|
-
return typeof self !== "undefined"
|
|
352
|
+
return typeof self !== "undefined"
|
|
353
|
+
? self
|
|
354
|
+
: typeof window !== "undefined"
|
|
355
|
+
? window
|
|
356
|
+
: global;
|
|
330
357
|
})();
|
|
331
358
|
|
|
332
|
-
const isContextDefined = (context) =>
|
|
359
|
+
const isContextDefined = (context) =>
|
|
360
|
+
!isUndefined(context) && context !== _global;
|
|
333
361
|
|
|
334
362
|
/**
|
|
335
363
|
* Accepts varargs expecting each argument to be an object, then
|
|
@@ -341,7 +369,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
341
369
|
* Example:
|
|
342
370
|
*
|
|
343
371
|
* ```js
|
|
344
|
-
*
|
|
372
|
+
* const result = merge({foo: 123}, {foo: 456});
|
|
345
373
|
* console.log(result.foo); // outputs 456
|
|
346
374
|
* ```
|
|
347
375
|
*
|
|
@@ -350,10 +378,15 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
350
378
|
* @returns {Object} Result of all merge properties
|
|
351
379
|
*/
|
|
352
380
|
function merge(/* obj1, obj2, obj3, ... */) {
|
|
353
|
-
const {caseless, skipUndefined} = isContextDefined(this) && this || {};
|
|
381
|
+
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
|
|
354
382
|
const result = {};
|
|
355
383
|
const assignValue = (val, key) => {
|
|
356
|
-
|
|
384
|
+
// Skip dangerous property names to prevent prototype pollution
|
|
385
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const targetKey = (caseless && findKey(result, key)) || key;
|
|
357
390
|
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
|
358
391
|
result[targetKey] = merge(result[targetKey], val);
|
|
359
392
|
} else if (isPlainObject(val)) {
|
|
@@ -378,17 +411,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
378
411
|
* @param {Object} b The object to copy properties from
|
|
379
412
|
* @param {Object} thisArg The object to bind function to
|
|
380
413
|
*
|
|
381
|
-
* @param {
|
|
414
|
+
* @param {Object} [options]
|
|
415
|
+
* @param {Boolean} [options.allOwnKeys]
|
|
382
416
|
* @returns {Object} The resulting value of object a
|
|
383
417
|
*/
|
|
384
|
-
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
385
|
-
forEach(
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
418
|
+
const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
419
|
+
forEach(
|
|
420
|
+
b,
|
|
421
|
+
(val, key) => {
|
|
422
|
+
if (thisArg && isFunction$1(val)) {
|
|
423
|
+
Object.defineProperty(a, key, {
|
|
424
|
+
value: bind(val, thisArg),
|
|
425
|
+
writable: true,
|
|
426
|
+
enumerable: true,
|
|
427
|
+
configurable: true,
|
|
428
|
+
});
|
|
429
|
+
} else {
|
|
430
|
+
Object.defineProperty(a, key, {
|
|
431
|
+
value: val,
|
|
432
|
+
writable: true,
|
|
433
|
+
enumerable: true,
|
|
434
|
+
configurable: true,
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
{ allOwnKeys },
|
|
439
|
+
);
|
|
392
440
|
return a;
|
|
393
441
|
};
|
|
394
442
|
|
|
@@ -400,7 +448,7 @@ const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
|
400
448
|
* @returns {string} content value without BOM
|
|
401
449
|
*/
|
|
402
450
|
const stripBOM = (content) => {
|
|
403
|
-
if (content.charCodeAt(0) ===
|
|
451
|
+
if (content.charCodeAt(0) === 0xfeff) {
|
|
404
452
|
content = content.slice(1);
|
|
405
453
|
}
|
|
406
454
|
return content;
|
|
@@ -416,10 +464,18 @@ const stripBOM = (content) => {
|
|
|
416
464
|
* @returns {void}
|
|
417
465
|
*/
|
|
418
466
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
419
|
-
constructor.prototype = Object.create(
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
467
|
+
constructor.prototype = Object.create(
|
|
468
|
+
superConstructor.prototype,
|
|
469
|
+
descriptors,
|
|
470
|
+
);
|
|
471
|
+
Object.defineProperty(constructor.prototype, "constructor", {
|
|
472
|
+
value: constructor,
|
|
473
|
+
writable: true,
|
|
474
|
+
enumerable: false,
|
|
475
|
+
configurable: true,
|
|
476
|
+
});
|
|
477
|
+
Object.defineProperty(constructor, "super", {
|
|
478
|
+
value: superConstructor.prototype,
|
|
423
479
|
});
|
|
424
480
|
props && Object.assign(constructor.prototype, props);
|
|
425
481
|
};
|
|
@@ -448,13 +504,20 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
|
|
|
448
504
|
i = props.length;
|
|
449
505
|
while (i-- > 0) {
|
|
450
506
|
prop = props[i];
|
|
451
|
-
if (
|
|
507
|
+
if (
|
|
508
|
+
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
|
|
509
|
+
!merged[prop]
|
|
510
|
+
) {
|
|
452
511
|
destObj[prop] = sourceObj[prop];
|
|
453
512
|
merged[prop] = true;
|
|
454
513
|
}
|
|
455
514
|
}
|
|
456
515
|
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
|
457
|
-
} while (
|
|
516
|
+
} while (
|
|
517
|
+
sourceObj &&
|
|
518
|
+
(!filter || filter(sourceObj, destObj)) &&
|
|
519
|
+
sourceObj !== Object.prototype
|
|
520
|
+
);
|
|
458
521
|
|
|
459
522
|
return destObj;
|
|
460
523
|
};
|
|
@@ -478,7 +541,6 @@ const endsWith = (str, searchString, position) => {
|
|
|
478
541
|
return lastIndex !== -1 && lastIndex === position;
|
|
479
542
|
};
|
|
480
543
|
|
|
481
|
-
|
|
482
544
|
/**
|
|
483
545
|
* Returns new array from array like object or null if failed
|
|
484
546
|
*
|
|
@@ -507,12 +569,12 @@ const toArray = (thing) => {
|
|
|
507
569
|
* @returns {Array}
|
|
508
570
|
*/
|
|
509
571
|
// eslint-disable-next-line func-names
|
|
510
|
-
const isTypedArray = (TypedArray => {
|
|
572
|
+
const isTypedArray = ((TypedArray) => {
|
|
511
573
|
// eslint-disable-next-line func-names
|
|
512
|
-
return thing => {
|
|
574
|
+
return (thing) => {
|
|
513
575
|
return TypedArray && thing instanceof TypedArray;
|
|
514
576
|
};
|
|
515
|
-
})(typeof Uint8Array !==
|
|
577
|
+
})(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
|
|
516
578
|
|
|
517
579
|
/**
|
|
518
580
|
* For each entry in the object, call the function with the key and value.
|
|
@@ -555,18 +617,22 @@ const matchAll = (regExp, str) => {
|
|
|
555
617
|
};
|
|
556
618
|
|
|
557
619
|
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
|
558
|
-
const isHTMLForm = kindOfTest(
|
|
620
|
+
const isHTMLForm = kindOfTest("HTMLFormElement");
|
|
559
621
|
|
|
560
|
-
const toCamelCase = str => {
|
|
561
|
-
return str
|
|
562
|
-
|
|
622
|
+
const toCamelCase = (str) => {
|
|
623
|
+
return str
|
|
624
|
+
.toLowerCase()
|
|
625
|
+
.replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
|
563
626
|
return p1.toUpperCase() + p2;
|
|
564
|
-
}
|
|
565
|
-
);
|
|
627
|
+
});
|
|
566
628
|
};
|
|
567
629
|
|
|
568
630
|
/* Creating a function that will check if an object has a property. */
|
|
569
|
-
const hasOwnProperty = (
|
|
631
|
+
const hasOwnProperty = (
|
|
632
|
+
({ hasOwnProperty }) =>
|
|
633
|
+
(obj, prop) =>
|
|
634
|
+
hasOwnProperty.call(obj, prop)
|
|
635
|
+
)(Object.prototype);
|
|
570
636
|
|
|
571
637
|
/**
|
|
572
638
|
* Determine if a value is a RegExp object
|
|
@@ -575,7 +641,7 @@ const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call
|
|
|
575
641
|
*
|
|
576
642
|
* @returns {boolean} True if value is a RegExp object, otherwise false
|
|
577
643
|
*/
|
|
578
|
-
const isRegExp = kindOfTest(
|
|
644
|
+
const isRegExp = kindOfTest("RegExp");
|
|
579
645
|
|
|
580
646
|
const reduceDescriptors = (obj, reducer) => {
|
|
581
647
|
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
@@ -599,7 +665,10 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
599
665
|
const freezeMethods = (obj) => {
|
|
600
666
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
601
667
|
// skip restricted props in strict mode
|
|
602
|
-
if (
|
|
668
|
+
if (
|
|
669
|
+
isFunction$1(obj) &&
|
|
670
|
+
["arguments", "caller", "callee"].indexOf(name) !== -1
|
|
671
|
+
) {
|
|
603
672
|
return false;
|
|
604
673
|
}
|
|
605
674
|
|
|
@@ -609,14 +678,14 @@ const freezeMethods = (obj) => {
|
|
|
609
678
|
|
|
610
679
|
descriptor.enumerable = false;
|
|
611
680
|
|
|
612
|
-
if (
|
|
681
|
+
if ("writable" in descriptor) {
|
|
613
682
|
descriptor.writable = false;
|
|
614
683
|
return;
|
|
615
684
|
}
|
|
616
685
|
|
|
617
686
|
if (!descriptor.set) {
|
|
618
687
|
descriptor.set = () => {
|
|
619
|
-
throw Error(
|
|
688
|
+
throw Error("Can not rewrite read-only method '" + name + "'");
|
|
620
689
|
};
|
|
621
690
|
}
|
|
622
691
|
});
|
|
@@ -626,12 +695,14 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
626
695
|
const obj = {};
|
|
627
696
|
|
|
628
697
|
const define = (arr) => {
|
|
629
|
-
arr.forEach(value => {
|
|
698
|
+
arr.forEach((value) => {
|
|
630
699
|
obj[value] = true;
|
|
631
700
|
});
|
|
632
701
|
};
|
|
633
702
|
|
|
634
|
-
isArray(arrayOrString)
|
|
703
|
+
isArray(arrayOrString)
|
|
704
|
+
? define(arrayOrString)
|
|
705
|
+
: define(String(arrayOrString).split(delimiter));
|
|
635
706
|
|
|
636
707
|
return obj;
|
|
637
708
|
};
|
|
@@ -639,11 +710,11 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
639
710
|
const noop = () => {};
|
|
640
711
|
|
|
641
712
|
const toFiniteNumber = (value, defaultValue) => {
|
|
642
|
-
return value != null && Number.isFinite(value = +value)
|
|
713
|
+
return value != null && Number.isFinite((value = +value))
|
|
714
|
+
? value
|
|
715
|
+
: defaultValue;
|
|
643
716
|
};
|
|
644
717
|
|
|
645
|
-
|
|
646
|
-
|
|
647
718
|
/**
|
|
648
719
|
* If the thing is a FormData object, return true, otherwise return false.
|
|
649
720
|
*
|
|
@@ -652,14 +723,18 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
|
652
723
|
* @returns {boolean}
|
|
653
724
|
*/
|
|
654
725
|
function isSpecCompliantForm(thing) {
|
|
655
|
-
return !!(
|
|
726
|
+
return !!(
|
|
727
|
+
thing &&
|
|
728
|
+
isFunction$1(thing.append) &&
|
|
729
|
+
thing[toStringTag] === "FormData" &&
|
|
730
|
+
thing[iterator]
|
|
731
|
+
);
|
|
656
732
|
}
|
|
657
733
|
|
|
658
734
|
const toJSONObject = (obj) => {
|
|
659
735
|
const stack = new Array(10);
|
|
660
736
|
|
|
661
737
|
const visit = (source, i) => {
|
|
662
|
-
|
|
663
738
|
if (isObject(source)) {
|
|
664
739
|
if (stack.indexOf(source) >= 0) {
|
|
665
740
|
return;
|
|
@@ -670,7 +745,7 @@ const toJSONObject = (obj) => {
|
|
|
670
745
|
return source;
|
|
671
746
|
}
|
|
672
747
|
|
|
673
|
-
if(!(
|
|
748
|
+
if (!("toJSON" in source)) {
|
|
674
749
|
stack[i] = source;
|
|
675
750
|
const target = isArray(source) ? [] : {};
|
|
676
751
|
|
|
@@ -691,10 +766,13 @@ const toJSONObject = (obj) => {
|
|
|
691
766
|
return visit(obj, 0);
|
|
692
767
|
};
|
|
693
768
|
|
|
694
|
-
const isAsyncFn = kindOfTest(
|
|
769
|
+
const isAsyncFn = kindOfTest("AsyncFunction");
|
|
695
770
|
|
|
696
771
|
const isThenable = (thing) =>
|
|
697
|
-
thing &&
|
|
772
|
+
thing &&
|
|
773
|
+
(isObject(thing) || isFunction$1(thing)) &&
|
|
774
|
+
isFunction$1(thing.then) &&
|
|
775
|
+
isFunction$1(thing.catch);
|
|
698
776
|
|
|
699
777
|
// original code
|
|
700
778
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
@@ -704,32 +782,35 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
|
704
782
|
return setImmediate;
|
|
705
783
|
}
|
|
706
784
|
|
|
707
|
-
return postMessageSupported
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
785
|
+
return postMessageSupported
|
|
786
|
+
? ((token, callbacks) => {
|
|
787
|
+
_global.addEventListener(
|
|
788
|
+
"message",
|
|
789
|
+
({ source, data }) => {
|
|
790
|
+
if (source === _global && data === token) {
|
|
791
|
+
callbacks.length && callbacks.shift()();
|
|
792
|
+
}
|
|
793
|
+
},
|
|
794
|
+
false,
|
|
795
|
+
);
|
|
713
796
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
isFunction$1(_global.postMessage)
|
|
722
|
-
);
|
|
797
|
+
return (cb) => {
|
|
798
|
+
callbacks.push(cb);
|
|
799
|
+
_global.postMessage(token, "*");
|
|
800
|
+
};
|
|
801
|
+
})(`axios@${Math.random()}`, [])
|
|
802
|
+
: (cb) => setTimeout(cb);
|
|
803
|
+
})(typeof setImmediate === "function", isFunction$1(_global.postMessage));
|
|
723
804
|
|
|
724
|
-
const asap =
|
|
725
|
-
|
|
805
|
+
const asap =
|
|
806
|
+
typeof queueMicrotask !== "undefined"
|
|
807
|
+
? queueMicrotask.bind(_global)
|
|
808
|
+
: (typeof process !== "undefined" && process.nextTick) || _setImmediate;
|
|
726
809
|
|
|
727
810
|
// *********************
|
|
728
811
|
|
|
729
|
-
|
|
730
812
|
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
731
813
|
|
|
732
|
-
|
|
733
814
|
var utils$1 = {
|
|
734
815
|
isArray,
|
|
735
816
|
isArrayBuffer,
|
|
@@ -787,113 +868,78 @@ var utils$1 = {
|
|
|
787
868
|
isThenable,
|
|
788
869
|
setImmediate: _setImmediate,
|
|
789
870
|
asap,
|
|
790
|
-
isIterable
|
|
871
|
+
isIterable,
|
|
791
872
|
};
|
|
792
873
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
*
|
|
802
|
-
* @returns {Error} The created error.
|
|
803
|
-
*/
|
|
804
|
-
function AxiosError(message, code, config, request, response) {
|
|
805
|
-
Error.call(this);
|
|
874
|
+
class AxiosError extends Error {
|
|
875
|
+
static from(error, code, config, request, response, customProps) {
|
|
876
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
877
|
+
axiosError.cause = error;
|
|
878
|
+
axiosError.name = error.name;
|
|
879
|
+
customProps && Object.assign(axiosError, customProps);
|
|
880
|
+
return axiosError;
|
|
881
|
+
}
|
|
806
882
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
883
|
+
/**
|
|
884
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
885
|
+
*
|
|
886
|
+
* @param {string} message The error message.
|
|
887
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
888
|
+
* @param {Object} [config] The config.
|
|
889
|
+
* @param {Object} [request] The request.
|
|
890
|
+
* @param {Object} [response] The response.
|
|
891
|
+
*
|
|
892
|
+
* @returns {Error} The created error.
|
|
893
|
+
*/
|
|
894
|
+
constructor(message, code, config, request, response) {
|
|
895
|
+
super(message);
|
|
896
|
+
this.name = 'AxiosError';
|
|
897
|
+
this.isAxiosError = true;
|
|
898
|
+
code && (this.code = code);
|
|
899
|
+
config && (this.config = config);
|
|
900
|
+
request && (this.request = request);
|
|
901
|
+
if (response) {
|
|
902
|
+
this.response = response;
|
|
903
|
+
this.status = response.status;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
812
906
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
907
|
+
toJSON() {
|
|
908
|
+
return {
|
|
909
|
+
// Standard
|
|
910
|
+
message: this.message,
|
|
911
|
+
name: this.name,
|
|
912
|
+
// Microsoft
|
|
913
|
+
description: this.description,
|
|
914
|
+
number: this.number,
|
|
915
|
+
// Mozilla
|
|
916
|
+
fileName: this.fileName,
|
|
917
|
+
lineNumber: this.lineNumber,
|
|
918
|
+
columnNumber: this.columnNumber,
|
|
919
|
+
stack: this.stack,
|
|
920
|
+
// Axios
|
|
921
|
+
config: utils$1.toJSONObject(this.config),
|
|
922
|
+
code: this.code,
|
|
923
|
+
status: this.status,
|
|
924
|
+
};
|
|
925
|
+
}
|
|
822
926
|
}
|
|
823
927
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
config: utils$1.toJSONObject(this.config),
|
|
840
|
-
code: this.code,
|
|
841
|
-
status: this.status
|
|
842
|
-
};
|
|
843
|
-
}
|
|
844
|
-
});
|
|
845
|
-
|
|
846
|
-
const prototype$1 = AxiosError.prototype;
|
|
847
|
-
const descriptors = {};
|
|
848
|
-
|
|
849
|
-
[
|
|
850
|
-
'ERR_BAD_OPTION_VALUE',
|
|
851
|
-
'ERR_BAD_OPTION',
|
|
852
|
-
'ECONNABORTED',
|
|
853
|
-
'ETIMEDOUT',
|
|
854
|
-
'ERR_NETWORK',
|
|
855
|
-
'ERR_FR_TOO_MANY_REDIRECTS',
|
|
856
|
-
'ERR_DEPRECATED',
|
|
857
|
-
'ERR_BAD_RESPONSE',
|
|
858
|
-
'ERR_BAD_REQUEST',
|
|
859
|
-
'ERR_CANCELED',
|
|
860
|
-
'ERR_NOT_SUPPORT',
|
|
861
|
-
'ERR_INVALID_URL'
|
|
862
|
-
// eslint-disable-next-line func-names
|
|
863
|
-
].forEach(code => {
|
|
864
|
-
descriptors[code] = {value: code};
|
|
865
|
-
});
|
|
866
|
-
|
|
867
|
-
Object.defineProperties(AxiosError, descriptors);
|
|
868
|
-
Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
|
869
|
-
|
|
870
|
-
// eslint-disable-next-line func-names
|
|
871
|
-
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
872
|
-
const axiosError = Object.create(prototype$1);
|
|
873
|
-
|
|
874
|
-
utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
|
875
|
-
return obj !== Error.prototype;
|
|
876
|
-
}, prop => {
|
|
877
|
-
return prop !== 'isAxiosError';
|
|
878
|
-
});
|
|
879
|
-
|
|
880
|
-
const msg = error && error.message ? error.message : 'Error';
|
|
881
|
-
|
|
882
|
-
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
|
|
883
|
-
const errCode = code == null && error ? error.code : code;
|
|
884
|
-
AxiosError.call(axiosError, msg, errCode, config, request, response);
|
|
885
|
-
|
|
886
|
-
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
|
|
887
|
-
if (error && axiosError.cause == null) {
|
|
888
|
-
Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
axiosError.name = (error && error.name) || 'Error';
|
|
892
|
-
|
|
893
|
-
customProps && Object.assign(axiosError, customProps);
|
|
894
|
-
|
|
895
|
-
return axiosError;
|
|
896
|
-
};
|
|
928
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
929
|
+
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
930
|
+
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
931
|
+
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
932
|
+
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
933
|
+
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
934
|
+
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
935
|
+
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
936
|
+
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
937
|
+
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
938
|
+
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
939
|
+
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
940
|
+
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
941
|
+
|
|
942
|
+
var AxiosError$1 = AxiosError;
|
|
897
943
|
|
|
898
944
|
// eslint-disable-next-line strict
|
|
899
945
|
var httpAdapter = null;
|
|
@@ -1018,7 +1064,7 @@ function toFormData(obj, formData, options) {
|
|
|
1018
1064
|
}
|
|
1019
1065
|
|
|
1020
1066
|
if (!useBlob && utils$1.isBlob(value)) {
|
|
1021
|
-
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
1067
|
+
throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
|
|
1022
1068
|
}
|
|
1023
1069
|
|
|
1024
1070
|
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
@@ -1192,29 +1238,26 @@ function encode(val) {
|
|
|
1192
1238
|
* @returns {string} The formatted url
|
|
1193
1239
|
*/
|
|
1194
1240
|
function buildURL(url, params, options) {
|
|
1195
|
-
/*eslint no-param-reassign:0*/
|
|
1196
1241
|
if (!params) {
|
|
1197
1242
|
return url;
|
|
1198
1243
|
}
|
|
1199
|
-
|
|
1244
|
+
|
|
1200
1245
|
const _encode = options && options.encode || encode;
|
|
1201
1246
|
|
|
1202
|
-
|
|
1203
|
-
options
|
|
1204
|
-
|
|
1205
|
-
};
|
|
1206
|
-
}
|
|
1247
|
+
const _options = utils$1.isFunction(options) ? {
|
|
1248
|
+
serialize: options
|
|
1249
|
+
} : options;
|
|
1207
1250
|
|
|
1208
|
-
const serializeFn =
|
|
1251
|
+
const serializeFn = _options && _options.serialize;
|
|
1209
1252
|
|
|
1210
1253
|
let serializedParams;
|
|
1211
1254
|
|
|
1212
1255
|
if (serializeFn) {
|
|
1213
|
-
serializedParams = serializeFn(params,
|
|
1256
|
+
serializedParams = serializeFn(params, _options);
|
|
1214
1257
|
} else {
|
|
1215
1258
|
serializedParams = utils$1.isURLSearchParams(params) ?
|
|
1216
1259
|
params.toString() :
|
|
1217
|
-
new AxiosURLSearchParams(params,
|
|
1260
|
+
new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1218
1261
|
}
|
|
1219
1262
|
|
|
1220
1263
|
if (serializedParams) {
|
|
@@ -1239,6 +1282,7 @@ class InterceptorManager {
|
|
|
1239
1282
|
*
|
|
1240
1283
|
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
1241
1284
|
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
1285
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
1242
1286
|
*
|
|
1243
1287
|
* @return {Number} An ID used to remove interceptor later
|
|
1244
1288
|
*/
|
|
@@ -1300,7 +1344,8 @@ var InterceptorManager$1 = InterceptorManager;
|
|
|
1300
1344
|
var transitionalDefaults = {
|
|
1301
1345
|
silentJSONParsing: true,
|
|
1302
1346
|
forcedJSONParsing: true,
|
|
1303
|
-
clarifyTimeoutError: false
|
|
1347
|
+
clarifyTimeoutError: false,
|
|
1348
|
+
legacyInterceptorReqResOrdering: true
|
|
1304
1349
|
};
|
|
1305
1350
|
|
|
1306
1351
|
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
@@ -1588,7 +1633,7 @@ const defaults = {
|
|
|
1588
1633
|
} catch (e) {
|
|
1589
1634
|
if (strictJSONParsing) {
|
|
1590
1635
|
if (e.name === 'SyntaxError') {
|
|
1591
|
-
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
|
1636
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
|
1592
1637
|
}
|
|
1593
1638
|
throw e;
|
|
1594
1639
|
}
|
|
@@ -2022,24 +2067,24 @@ function isCancel(value) {
|
|
|
2022
2067
|
return !!(value && value.__CANCEL__);
|
|
2023
2068
|
}
|
|
2024
2069
|
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2070
|
+
class CanceledError extends AxiosError$1 {
|
|
2071
|
+
/**
|
|
2072
|
+
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
2073
|
+
*
|
|
2074
|
+
* @param {string=} message The message.
|
|
2075
|
+
* @param {Object=} config The config.
|
|
2076
|
+
* @param {Object=} request The request.
|
|
2077
|
+
*
|
|
2078
|
+
* @returns {CanceledError} The created error.
|
|
2079
|
+
*/
|
|
2080
|
+
constructor(message, config, request) {
|
|
2081
|
+
super(message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
|
|
2082
|
+
this.name = 'CanceledError';
|
|
2083
|
+
this.__CANCEL__ = true;
|
|
2084
|
+
}
|
|
2038
2085
|
}
|
|
2039
2086
|
|
|
2040
|
-
|
|
2041
|
-
__CANCEL__: true
|
|
2042
|
-
});
|
|
2087
|
+
var CanceledError$1 = CanceledError;
|
|
2043
2088
|
|
|
2044
2089
|
/**
|
|
2045
2090
|
* Resolve or reject a Promise based on response status.
|
|
@@ -2055,9 +2100,9 @@ function settle(resolve, reject, response) {
|
|
|
2055
2100
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
2056
2101
|
resolve(response);
|
|
2057
2102
|
} else {
|
|
2058
|
-
reject(new AxiosError(
|
|
2103
|
+
reject(new AxiosError$1(
|
|
2059
2104
|
'Request failed with status code ' + response.status,
|
|
2060
|
-
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
2105
|
+
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
2061
2106
|
response.config,
|
|
2062
2107
|
response.request,
|
|
2063
2108
|
response
|
|
@@ -2280,6 +2325,10 @@ function isAbsoluteURL(url) {
|
|
|
2280
2325
|
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
2281
2326
|
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
2282
2327
|
// by any combination of letters, digits, plus, period, or hyphen.
|
|
2328
|
+
if (typeof url !== 'string') {
|
|
2329
|
+
return false;
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2283
2332
|
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
2284
2333
|
}
|
|
2285
2334
|
|
|
@@ -2315,7 +2364,8 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
|
2315
2364
|
return requestedURL;
|
|
2316
2365
|
}
|
|
2317
2366
|
|
|
2318
|
-
const headersToObject = (thing) =>
|
|
2367
|
+
const headersToObject = (thing) =>
|
|
2368
|
+
thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
|
2319
2369
|
|
|
2320
2370
|
/**
|
|
2321
2371
|
* Config-specific merge-function which creates a new config-object
|
|
@@ -2333,7 +2383,7 @@ function mergeConfig(config1, config2) {
|
|
|
2333
2383
|
|
|
2334
2384
|
function getMergedValue(target, source, prop, caseless) {
|
|
2335
2385
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
2336
|
-
return utils$1.merge.call({caseless}, target, source);
|
|
2386
|
+
return utils$1.merge.call({ caseless }, target, source);
|
|
2337
2387
|
} else if (utils$1.isPlainObject(source)) {
|
|
2338
2388
|
return utils$1.merge({}, source);
|
|
2339
2389
|
} else if (utils$1.isArray(source)) {
|
|
@@ -2342,7 +2392,6 @@ function mergeConfig(config1, config2) {
|
|
|
2342
2392
|
return source;
|
|
2343
2393
|
}
|
|
2344
2394
|
|
|
2345
|
-
// eslint-disable-next-line consistent-return
|
|
2346
2395
|
function mergeDeepProperties(a, b, prop, caseless) {
|
|
2347
2396
|
if (!utils$1.isUndefined(b)) {
|
|
2348
2397
|
return getMergedValue(a, b, prop, caseless);
|
|
@@ -2405,14 +2454,27 @@ function mergeConfig(config1, config2) {
|
|
|
2405
2454
|
socketPath: defaultToConfig2,
|
|
2406
2455
|
responseEncoding: defaultToConfig2,
|
|
2407
2456
|
validateStatus: mergeDirectKeys,
|
|
2408
|
-
headers: (a, b, prop) =>
|
|
2457
|
+
headers: (a, b, prop) =>
|
|
2458
|
+
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
2409
2459
|
};
|
|
2410
2460
|
|
|
2411
|
-
utils$1.forEach(
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2461
|
+
utils$1.forEach(
|
|
2462
|
+
Object.keys({ ...config1, ...config2 }),
|
|
2463
|
+
function computeConfigValue(prop) {
|
|
2464
|
+
if (
|
|
2465
|
+
prop === "__proto__" ||
|
|
2466
|
+
prop === "constructor" ||
|
|
2467
|
+
prop === "prototype"
|
|
2468
|
+
)
|
|
2469
|
+
return;
|
|
2470
|
+
const merge = utils$1.hasOwnProp(mergeMap, prop)
|
|
2471
|
+
? mergeMap[prop]
|
|
2472
|
+
: mergeDeepProperties;
|
|
2473
|
+
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2474
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
|
|
2475
|
+
(config[prop] = configValue);
|
|
2476
|
+
},
|
|
2477
|
+
);
|
|
2416
2478
|
|
|
2417
2479
|
return config;
|
|
2418
2480
|
}
|
|
@@ -2557,7 +2619,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2557
2619
|
return;
|
|
2558
2620
|
}
|
|
2559
2621
|
|
|
2560
|
-
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
|
2622
|
+
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
|
2561
2623
|
|
|
2562
2624
|
// Clean up request
|
|
2563
2625
|
request = null;
|
|
@@ -2569,7 +2631,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2569
2631
|
// (message may be empty; when present, surface it)
|
|
2570
2632
|
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
2571
2633
|
const msg = event && event.message ? event.message : 'Network Error';
|
|
2572
|
-
const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
|
|
2634
|
+
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
2573
2635
|
// attach the underlying event for consumers who want details
|
|
2574
2636
|
err.event = event || null;
|
|
2575
2637
|
reject(err);
|
|
@@ -2583,9 +2645,9 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2583
2645
|
if (_config.timeoutErrorMessage) {
|
|
2584
2646
|
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
2585
2647
|
}
|
|
2586
|
-
reject(new AxiosError(
|
|
2648
|
+
reject(new AxiosError$1(
|
|
2587
2649
|
timeoutErrorMessage,
|
|
2588
|
-
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
|
2650
|
+
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
2589
2651
|
config,
|
|
2590
2652
|
request));
|
|
2591
2653
|
|
|
@@ -2635,7 +2697,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2635
2697
|
if (!request) {
|
|
2636
2698
|
return;
|
|
2637
2699
|
}
|
|
2638
|
-
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
|
2700
|
+
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
2639
2701
|
request.abort();
|
|
2640
2702
|
request = null;
|
|
2641
2703
|
};
|
|
@@ -2649,7 +2711,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2649
2711
|
const protocol = parseProtocol(_config.url);
|
|
2650
2712
|
|
|
2651
2713
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
2652
|
-
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
|
2714
|
+
reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
|
|
2653
2715
|
return;
|
|
2654
2716
|
}
|
|
2655
2717
|
|
|
@@ -2672,13 +2734,13 @@ const composeSignals = (signals, timeout) => {
|
|
|
2672
2734
|
aborted = true;
|
|
2673
2735
|
unsubscribe();
|
|
2674
2736
|
const err = reason instanceof Error ? reason : this.reason;
|
|
2675
|
-
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
2737
|
+
controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
|
|
2676
2738
|
}
|
|
2677
2739
|
};
|
|
2678
2740
|
|
|
2679
2741
|
let timer = timeout && setTimeout(() => {
|
|
2680
2742
|
timer = null;
|
|
2681
|
-
onabort(new AxiosError(`timeout ${timeout}
|
|
2743
|
+
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
2682
2744
|
}, timeout);
|
|
2683
2745
|
|
|
2684
2746
|
const unsubscribe = () => {
|
|
@@ -2864,7 +2926,7 @@ const factory = (env) => {
|
|
|
2864
2926
|
return method.call(res);
|
|
2865
2927
|
}
|
|
2866
2928
|
|
|
2867
|
-
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
2929
|
+
throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
|
|
2868
2930
|
});
|
|
2869
2931
|
});
|
|
2870
2932
|
})());
|
|
@@ -3030,14 +3092,14 @@ const factory = (env) => {
|
|
|
3030
3092
|
|
|
3031
3093
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3032
3094
|
throw Object.assign(
|
|
3033
|
-
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
|
3095
|
+
new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request, err && err.response),
|
|
3034
3096
|
{
|
|
3035
3097
|
cause: err.cause || err
|
|
3036
3098
|
}
|
|
3037
3099
|
)
|
|
3038
3100
|
}
|
|
3039
3101
|
|
|
3040
|
-
throw AxiosError.from(err, err && err.code, config, request);
|
|
3102
|
+
throw AxiosError$1.from(err, err && err.code, config, request, err && err.response);
|
|
3041
3103
|
}
|
|
3042
3104
|
}
|
|
3043
3105
|
};
|
|
@@ -3142,7 +3204,7 @@ function getAdapter(adapters, config) {
|
|
|
3142
3204
|
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
3143
3205
|
|
|
3144
3206
|
if (adapter === undefined) {
|
|
3145
|
-
throw new AxiosError(`Unknown adapter '${id}'`);
|
|
3207
|
+
throw new AxiosError$1(`Unknown adapter '${id}'`);
|
|
3146
3208
|
}
|
|
3147
3209
|
}
|
|
3148
3210
|
|
|
@@ -3163,7 +3225,7 @@ function getAdapter(adapters, config) {
|
|
|
3163
3225
|
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
|
3164
3226
|
'as no adapter specified';
|
|
3165
3227
|
|
|
3166
|
-
throw new AxiosError(
|
|
3228
|
+
throw new AxiosError$1(
|
|
3167
3229
|
`There is no suitable adapter to dispatch the request ` + s,
|
|
3168
3230
|
'ERR_NOT_SUPPORT'
|
|
3169
3231
|
);
|
|
@@ -3202,7 +3264,7 @@ function throwIfCancellationRequested(config) {
|
|
|
3202
3264
|
}
|
|
3203
3265
|
|
|
3204
3266
|
if (config.signal && config.signal.aborted) {
|
|
3205
|
-
throw new CanceledError(null, config);
|
|
3267
|
+
throw new CanceledError$1(null, config);
|
|
3206
3268
|
}
|
|
3207
3269
|
}
|
|
3208
3270
|
|
|
@@ -3262,7 +3324,7 @@ function dispatchRequest(config) {
|
|
|
3262
3324
|
});
|
|
3263
3325
|
}
|
|
3264
3326
|
|
|
3265
|
-
const VERSION = "1.13.
|
|
3327
|
+
const VERSION = "1.13.5";
|
|
3266
3328
|
|
|
3267
3329
|
const validators$1 = {};
|
|
3268
3330
|
|
|
@@ -3292,9 +3354,9 @@ validators$1.transitional = function transitional(validator, version, message) {
|
|
|
3292
3354
|
// eslint-disable-next-line func-names
|
|
3293
3355
|
return (value, opt, opts) => {
|
|
3294
3356
|
if (validator === false) {
|
|
3295
|
-
throw new AxiosError(
|
|
3357
|
+
throw new AxiosError$1(
|
|
3296
3358
|
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
|
|
3297
|
-
AxiosError.ERR_DEPRECATED
|
|
3359
|
+
AxiosError$1.ERR_DEPRECATED
|
|
3298
3360
|
);
|
|
3299
3361
|
}
|
|
3300
3362
|
|
|
@@ -3333,7 +3395,7 @@ validators$1.spelling = function spelling(correctSpelling) {
|
|
|
3333
3395
|
|
|
3334
3396
|
function assertOptions(options, schema, allowUnknown) {
|
|
3335
3397
|
if (typeof options !== 'object') {
|
|
3336
|
-
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
|
|
3398
|
+
throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
3337
3399
|
}
|
|
3338
3400
|
const keys = Object.keys(options);
|
|
3339
3401
|
let i = keys.length;
|
|
@@ -3344,12 +3406,12 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
3344
3406
|
const value = options[opt];
|
|
3345
3407
|
const result = value === undefined || validator(value, opt, options);
|
|
3346
3408
|
if (result !== true) {
|
|
3347
|
-
throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
|
3409
|
+
throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
3348
3410
|
}
|
|
3349
3411
|
continue;
|
|
3350
3412
|
}
|
|
3351
3413
|
if (allowUnknown !== true) {
|
|
3352
|
-
throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
|
|
3414
|
+
throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
|
|
3353
3415
|
}
|
|
3354
3416
|
}
|
|
3355
3417
|
}
|
|
@@ -3430,7 +3492,8 @@ class Axios {
|
|
|
3430
3492
|
validator.assertOptions(transitional, {
|
|
3431
3493
|
silentJSONParsing: validators.transitional(validators.boolean),
|
|
3432
3494
|
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
3433
|
-
clarifyTimeoutError: validators.transitional(validators.boolean)
|
|
3495
|
+
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
3496
|
+
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
|
|
3434
3497
|
}, false);
|
|
3435
3498
|
}
|
|
3436
3499
|
|
|
@@ -3487,7 +3550,14 @@ class Axios {
|
|
|
3487
3550
|
|
|
3488
3551
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
3489
3552
|
|
|
3490
|
-
|
|
3553
|
+
const transitional = config.transitional || transitionalDefaults;
|
|
3554
|
+
const legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
|
|
3555
|
+
|
|
3556
|
+
if (legacyInterceptorReqResOrdering) {
|
|
3557
|
+
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
3558
|
+
} else {
|
|
3559
|
+
requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
3560
|
+
}
|
|
3491
3561
|
});
|
|
3492
3562
|
|
|
3493
3563
|
const responseInterceptorChain = [];
|
|
@@ -3642,7 +3712,7 @@ class CancelToken {
|
|
|
3642
3712
|
return;
|
|
3643
3713
|
}
|
|
3644
3714
|
|
|
3645
|
-
token.reason = new CanceledError(message, config, request);
|
|
3715
|
+
token.reason = new CanceledError$1(message, config, request);
|
|
3646
3716
|
resolvePromise(token.reason);
|
|
3647
3717
|
});
|
|
3648
3718
|
}
|
|
@@ -3726,7 +3796,7 @@ var CancelToken$1 = CancelToken;
|
|
|
3726
3796
|
*
|
|
3727
3797
|
* ```js
|
|
3728
3798
|
* function f(x, y, z) {}
|
|
3729
|
-
*
|
|
3799
|
+
* const args = [1, 2, 3];
|
|
3730
3800
|
* f.apply(null, args);
|
|
3731
3801
|
* ```
|
|
3732
3802
|
*
|
|
@@ -3867,14 +3937,14 @@ const axios = createInstance(defaults$1);
|
|
|
3867
3937
|
axios.Axios = Axios$1;
|
|
3868
3938
|
|
|
3869
3939
|
// Expose Cancel & CancelToken
|
|
3870
|
-
axios.CanceledError = CanceledError;
|
|
3940
|
+
axios.CanceledError = CanceledError$1;
|
|
3871
3941
|
axios.CancelToken = CancelToken$1;
|
|
3872
3942
|
axios.isCancel = isCancel;
|
|
3873
3943
|
axios.VERSION = VERSION;
|
|
3874
3944
|
axios.toFormData = toFormData;
|
|
3875
3945
|
|
|
3876
3946
|
// Expose AxiosError class
|
|
3877
|
-
axios.AxiosError = AxiosError;
|
|
3947
|
+
axios.AxiosError = AxiosError$1;
|
|
3878
3948
|
|
|
3879
3949
|
// alias for CanceledError for backward compatibility
|
|
3880
3950
|
axios.Cancel = axios.CanceledError;
|
|
@@ -3906,7 +3976,7 @@ axios.default = axios;
|
|
|
3906
3976
|
var axios$1 = axios;
|
|
3907
3977
|
|
|
3908
3978
|
var name$1 = "@tryghost/content-api";
|
|
3909
|
-
var version = "1.12.
|
|
3979
|
+
var version = "1.12.4";
|
|
3910
3980
|
var repository = {
|
|
3911
3981
|
type: "git",
|
|
3912
3982
|
url: "git+https://github.com/TryGhost/SDK.git",
|
|
@@ -3929,7 +3999,7 @@ var files = [
|
|
|
3929
3999
|
var scripts = {
|
|
3930
4000
|
dev: "echo \"Implement me!\"",
|
|
3931
4001
|
pretest: "yarn build",
|
|
3932
|
-
test: "NODE_ENV=testing c8 --
|
|
4002
|
+
test: "NODE_ENV=testing c8 --src cjs --reporter text --reporter cobertura mocha './test/**/*.test.js'",
|
|
3933
4003
|
build: "rollup -c",
|
|
3934
4004
|
lint: "eslint . --ext .js --cache",
|
|
3935
4005
|
prepare: "NODE_ENV=production yarn build",
|
|
@@ -3939,27 +4009,28 @@ var publishConfig = {
|
|
|
3939
4009
|
access: "public"
|
|
3940
4010
|
};
|
|
3941
4011
|
var devDependencies = {
|
|
3942
|
-
"@babel/core": "7.
|
|
4012
|
+
"@babel/core": "7.29.0",
|
|
3943
4013
|
"@babel/polyfill": "7.12.1",
|
|
3944
|
-
"@babel/preset-env": "7.
|
|
4014
|
+
"@babel/preset-env": "7.29.0",
|
|
4015
|
+
"@rollup/plugin-babel": "6.1.0",
|
|
3945
4016
|
"@rollup/plugin-json": "6.1.0",
|
|
3946
|
-
|
|
3947
|
-
"
|
|
3948
|
-
|
|
4017
|
+
"@rollup/plugin-node-resolve": "16.0.3",
|
|
4018
|
+
"@rollup/plugin-terser": "0.4.4",
|
|
4019
|
+
c8: "11.0.0",
|
|
4020
|
+
"core-js": "3.48.0",
|
|
4021
|
+
"eslint-plugin-ghost": "3.4.4",
|
|
3949
4022
|
mocha: "11.7.5",
|
|
3950
|
-
rollup: "2.
|
|
3951
|
-
"rollup-plugin-babel": "4.4.0",
|
|
4023
|
+
rollup: "2.80.0",
|
|
3952
4024
|
"rollup-plugin-commonjs": "10.1.0",
|
|
3953
|
-
"rollup-plugin-node
|
|
3954
|
-
"rollup-plugin-polyfill-node": "0.12.0",
|
|
4025
|
+
"rollup-plugin-polyfill-node": "0.13.0",
|
|
3955
4026
|
"rollup-plugin-replace": "2.2.0",
|
|
3956
|
-
"rollup-plugin-terser": "7.0.2",
|
|
3957
4027
|
should: "13.2.3",
|
|
3958
|
-
sinon: "21.0.
|
|
4028
|
+
sinon: "21.0.1"
|
|
3959
4029
|
};
|
|
3960
4030
|
var dependencies = {
|
|
3961
|
-
axios: "
|
|
4031
|
+
axios: "1.13.5"
|
|
3962
4032
|
};
|
|
4033
|
+
var gitHead = "2c937c80e98d9bad4458e1c2e9d6f6b138bd308e";
|
|
3963
4034
|
var packageInfo = {
|
|
3964
4035
|
name: name$1,
|
|
3965
4036
|
version: version,
|
|
@@ -3975,7 +4046,8 @@ var packageInfo = {
|
|
|
3975
4046
|
scripts: scripts,
|
|
3976
4047
|
publishConfig: publishConfig,
|
|
3977
4048
|
devDependencies: devDependencies,
|
|
3978
|
-
dependencies: dependencies
|
|
4049
|
+
dependencies: dependencies,
|
|
4050
|
+
gitHead: gitHead
|
|
3979
4051
|
};
|
|
3980
4052
|
|
|
3981
4053
|
// @NOTE: this value is dynamically replaced based on browser/node environment
|