@naturalcycles/js-lib 14.166.0 → 14.166.1
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/dist/http/fetcher.js +3 -1
- package/dist-esm/http/fetcher.js +3 -2
- package/package.json +1 -1
- package/src/http/fetcher.ts +4 -3
package/dist/http/fetcher.js
CHANGED
|
@@ -524,6 +524,7 @@ class Fetcher {
|
|
|
524
524
|
},
|
|
525
525
|
init: (0, object_util_1._merge)({
|
|
526
526
|
...this.cfg.init,
|
|
527
|
+
headers: { ...this.cfg.init.headers },
|
|
527
528
|
method: opt.method || this.cfg.init.method,
|
|
528
529
|
credentials: opt.credentials || this.cfg.init.credentials,
|
|
529
530
|
redirect: opt.redirect || this.cfg.init.redirect || 'follow',
|
|
@@ -549,6 +550,7 @@ class Fetcher {
|
|
|
549
550
|
req.fullUrl += (req.fullUrl.includes('?') ? '&' : '?') + qs;
|
|
550
551
|
}
|
|
551
552
|
// setup request body
|
|
553
|
+
// Unless it's a well-defined input type (json, text) - content-type is set automatically by the native fetch
|
|
552
554
|
if (opt.json !== undefined) {
|
|
553
555
|
req.init.body = JSON.stringify(opt.json);
|
|
554
556
|
req.init.headers['content-type'] = 'application/json';
|
|
@@ -563,8 +565,8 @@ class Fetcher {
|
|
|
563
565
|
}
|
|
564
566
|
else {
|
|
565
567
|
req.init.body = new URLSearchParams(opt.form);
|
|
568
|
+
req.init.headers['content-type'] = 'application/x-www-form-urlencoded';
|
|
566
569
|
}
|
|
567
|
-
req.init.headers['content-type'] = 'application/x-www-form-urlencoded';
|
|
568
570
|
}
|
|
569
571
|
else if (opt.body !== undefined) {
|
|
570
572
|
req.init.body = opt.body;
|
package/dist-esm/http/fetcher.js
CHANGED
|
@@ -500,7 +500,7 @@ export class Fetcher {
|
|
|
500
500
|
'logResponse',
|
|
501
501
|
'logResponseBody',
|
|
502
502
|
'debug',
|
|
503
|
-
])), { started: Date.now() }), _omit(opt, ['method', 'headers', 'credentials'])), { inputUrl: opt.url || '', fullUrl: opt.url || '', retry: Object.assign(Object.assign({}, this.cfg.retry), _filterUndefinedValues(opt.retry || {})), init: _merge(Object.assign(Object.assign({}, this.cfg.init), { method: opt.method || this.cfg.init.method, credentials: opt.credentials || this.cfg.init.credentials, redirect: opt.redirect || this.cfg.init.redirect || 'follow' }), {
|
|
503
|
+
])), { started: Date.now() }), _omit(opt, ['method', 'headers', 'credentials'])), { inputUrl: opt.url || '', fullUrl: opt.url || '', retry: Object.assign(Object.assign({}, this.cfg.retry), _filterUndefinedValues(opt.retry || {})), init: _merge(Object.assign(Object.assign({}, this.cfg.init), { headers: Object.assign({}, this.cfg.init.headers), method: opt.method || this.cfg.init.method, credentials: opt.credentials || this.cfg.init.credentials, redirect: opt.redirect || this.cfg.init.redirect || 'follow' }), {
|
|
504
504
|
headers: _mapKeys(opt.headers || {}, k => k.toLowerCase()),
|
|
505
505
|
}) });
|
|
506
506
|
// setup url
|
|
@@ -518,6 +518,7 @@ export class Fetcher {
|
|
|
518
518
|
req.fullUrl += (req.fullUrl.includes('?') ? '&' : '?') + qs;
|
|
519
519
|
}
|
|
520
520
|
// setup request body
|
|
521
|
+
// Unless it's a well-defined input type (json, text) - content-type is set automatically by the native fetch
|
|
521
522
|
if (opt.json !== undefined) {
|
|
522
523
|
req.init.body = JSON.stringify(opt.json);
|
|
523
524
|
req.init.headers['content-type'] = 'application/json';
|
|
@@ -532,8 +533,8 @@ export class Fetcher {
|
|
|
532
533
|
}
|
|
533
534
|
else {
|
|
534
535
|
req.init.body = new URLSearchParams(opt.form);
|
|
536
|
+
req.init.headers['content-type'] = 'application/x-www-form-urlencoded';
|
|
535
537
|
}
|
|
536
|
-
req.init.headers['content-type'] = 'application/x-www-form-urlencoded';
|
|
537
538
|
}
|
|
538
539
|
else if (opt.body !== undefined) {
|
|
539
540
|
req.init.body = opt.body;
|
package/package.json
CHANGED
package/src/http/fetcher.ts
CHANGED
|
@@ -637,13 +637,14 @@ export class Fetcher {
|
|
|
637
637
|
init: _merge(
|
|
638
638
|
{
|
|
639
639
|
...this.cfg.init,
|
|
640
|
+
headers: { ...this.cfg.init.headers }, // this avoids mutation
|
|
640
641
|
method: opt.method || this.cfg.init.method,
|
|
641
642
|
credentials: opt.credentials || this.cfg.init.credentials,
|
|
642
643
|
redirect: opt.redirect || this.cfg.init.redirect || 'follow',
|
|
643
644
|
},
|
|
644
645
|
{
|
|
645
646
|
headers: _mapKeys(opt.headers || {}, k => k.toLowerCase()),
|
|
646
|
-
}
|
|
647
|
+
} satisfies RequestInit,
|
|
647
648
|
),
|
|
648
649
|
}
|
|
649
650
|
// setup url
|
|
@@ -667,6 +668,7 @@ export class Fetcher {
|
|
|
667
668
|
}
|
|
668
669
|
|
|
669
670
|
// setup request body
|
|
671
|
+
// Unless it's a well-defined input type (json, text) - content-type is set automatically by the native fetch
|
|
670
672
|
if (opt.json !== undefined) {
|
|
671
673
|
req.init.body = JSON.stringify(opt.json)
|
|
672
674
|
req.init.headers['content-type'] = 'application/json'
|
|
@@ -678,9 +680,8 @@ export class Fetcher {
|
|
|
678
680
|
req.init.body = opt.form
|
|
679
681
|
} else {
|
|
680
682
|
req.init.body = new URLSearchParams(opt.form)
|
|
683
|
+
req.init.headers['content-type'] = 'application/x-www-form-urlencoded'
|
|
681
684
|
}
|
|
682
|
-
|
|
683
|
-
req.init.headers['content-type'] = 'application/x-www-form-urlencoded'
|
|
684
685
|
} else if (opt.body !== undefined) {
|
|
685
686
|
req.init.body = opt.body
|
|
686
687
|
}
|