superagent 6.0.0 → 6.1.0

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.
@@ -371,6 +371,797 @@ function replaceGetterValues(replacer) {
371
371
  }
372
372
 
373
373
  },{}],3:[function(require,module,exports){
374
+ 'use strict';
375
+
376
+ var replace = String.prototype.replace;
377
+ var percentTwenties = /%20/g;
378
+
379
+ var util = require('./utils');
380
+
381
+ var Format = {
382
+ RFC1738: 'RFC1738',
383
+ RFC3986: 'RFC3986'
384
+ };
385
+ module.exports = util.assign({
386
+ 'default': Format.RFC3986,
387
+ formatters: {
388
+ RFC1738: function RFC1738(value) {
389
+ return replace.call(value, percentTwenties, '+');
390
+ },
391
+ RFC3986: function RFC3986(value) {
392
+ return String(value);
393
+ }
394
+ }
395
+ }, Format);
396
+
397
+ },{"./utils":7}],4:[function(require,module,exports){
398
+ 'use strict';
399
+
400
+ var stringify = require('./stringify');
401
+
402
+ var parse = require('./parse');
403
+
404
+ var formats = require('./formats');
405
+
406
+ module.exports = {
407
+ formats: formats,
408
+ parse: parse,
409
+ stringify: stringify
410
+ };
411
+
412
+ },{"./formats":3,"./parse":5,"./stringify":6}],5:[function(require,module,exports){
413
+ 'use strict';
414
+
415
+ var utils = require('./utils');
416
+
417
+ var has = Object.prototype.hasOwnProperty;
418
+ var isArray = Array.isArray;
419
+ var defaults = {
420
+ allowDots: false,
421
+ allowPrototypes: false,
422
+ arrayLimit: 20,
423
+ charset: 'utf-8',
424
+ charsetSentinel: false,
425
+ comma: false,
426
+ decoder: utils.decode,
427
+ delimiter: '&',
428
+ depth: 5,
429
+ ignoreQueryPrefix: false,
430
+ interpretNumericEntities: false,
431
+ parameterLimit: 1000,
432
+ parseArrays: true,
433
+ plainObjects: false,
434
+ strictNullHandling: false
435
+ };
436
+
437
+ var interpretNumericEntities = function interpretNumericEntities(str) {
438
+ return str.replace(/&#(\d+);/g, function ($0, numberStr) {
439
+ return String.fromCharCode(parseInt(numberStr, 10));
440
+ });
441
+ };
442
+
443
+ var parseArrayValue = function parseArrayValue(val, options) {
444
+ if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
445
+ return val.split(',');
446
+ }
447
+
448
+ return val;
449
+ }; // This is what browsers will submit when the ✓ character occurs in an
450
+ // application/x-www-form-urlencoded body and the encoding of the page containing
451
+ // the form is iso-8859-1, or when the submitted form has an accept-charset
452
+ // attribute of iso-8859-1. Presumably also with other charsets that do not contain
453
+ // the ✓ character, such as us-ascii.
454
+
455
+
456
+ var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓')
457
+ // These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
458
+
459
+ var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
460
+
461
+ var parseValues = function parseQueryStringValues(str, options) {
462
+ var obj = {};
463
+ var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
464
+ var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
465
+ var parts = cleanStr.split(options.delimiter, limit);
466
+ var skipIndex = -1; // Keep track of where the utf8 sentinel was found
467
+
468
+ var i;
469
+ var charset = options.charset;
470
+
471
+ if (options.charsetSentinel) {
472
+ for (i = 0; i < parts.length; ++i) {
473
+ if (parts[i].indexOf('utf8=') === 0) {
474
+ if (parts[i] === charsetSentinel) {
475
+ charset = 'utf-8';
476
+ } else if (parts[i] === isoSentinel) {
477
+ charset = 'iso-8859-1';
478
+ }
479
+
480
+ skipIndex = i;
481
+ i = parts.length; // The eslint settings do not allow break;
482
+ }
483
+ }
484
+ }
485
+
486
+ for (i = 0; i < parts.length; ++i) {
487
+ if (i === skipIndex) {
488
+ continue;
489
+ }
490
+
491
+ var part = parts[i];
492
+ var bracketEqualsPos = part.indexOf(']=');
493
+ var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
494
+ var key, val;
495
+
496
+ if (pos === -1) {
497
+ key = options.decoder(part, defaults.decoder, charset, 'key');
498
+ val = options.strictNullHandling ? null : '';
499
+ } else {
500
+ key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key');
501
+ val = utils.maybeMap(parseArrayValue(part.slice(pos + 1), options), function (encodedVal) {
502
+ return options.decoder(encodedVal, defaults.decoder, charset, 'value');
503
+ });
504
+ }
505
+
506
+ if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
507
+ val = interpretNumericEntities(val);
508
+ }
509
+
510
+ if (part.indexOf('[]=') > -1) {
511
+ val = isArray(val) ? [val] : val;
512
+ }
513
+
514
+ if (has.call(obj, key)) {
515
+ obj[key] = utils.combine(obj[key], val);
516
+ } else {
517
+ obj[key] = val;
518
+ }
519
+ }
520
+
521
+ return obj;
522
+ };
523
+
524
+ var parseObject = function parseObject(chain, val, options, valuesParsed) {
525
+ var leaf = valuesParsed ? val : parseArrayValue(val, options);
526
+
527
+ for (var i = chain.length - 1; i >= 0; --i) {
528
+ var obj;
529
+ var root = chain[i];
530
+
531
+ if (root === '[]' && options.parseArrays) {
532
+ obj = [].concat(leaf);
533
+ } else {
534
+ obj = options.plainObjects ? Object.create(null) : {};
535
+ var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
536
+ var index = parseInt(cleanRoot, 10);
537
+
538
+ if (!options.parseArrays && cleanRoot === '') {
539
+ obj = {
540
+ 0: leaf
541
+ };
542
+ } else if (!isNaN(index) && root !== cleanRoot && String(index) === cleanRoot && index >= 0 && options.parseArrays && index <= options.arrayLimit) {
543
+ obj = [];
544
+ obj[index] = leaf;
545
+ } else {
546
+ obj[cleanRoot] = leaf;
547
+ }
548
+ }
549
+
550
+ leaf = obj; // eslint-disable-line no-param-reassign
551
+ }
552
+
553
+ return leaf;
554
+ };
555
+
556
+ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
557
+ if (!givenKey) {
558
+ return;
559
+ } // Transform dot notation to bracket notation
560
+
561
+
562
+ var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; // The regex chunks
563
+
564
+ var brackets = /(\[[^[\]]*])/;
565
+ var child = /(\[[^[\]]*])/g; // Get the parent
566
+
567
+ var segment = options.depth > 0 && brackets.exec(key);
568
+ var parent = segment ? key.slice(0, segment.index) : key; // Stash the parent if it exists
569
+
570
+ var keys = [];
571
+
572
+ if (parent) {
573
+ // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
574
+ if (!options.plainObjects && has.call(Object.prototype, parent)) {
575
+ if (!options.allowPrototypes) {
576
+ return;
577
+ }
578
+ }
579
+
580
+ keys.push(parent);
581
+ } // Loop through children appending to the array until we hit depth
582
+
583
+
584
+ var i = 0;
585
+
586
+ while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
587
+ i += 1;
588
+
589
+ if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
590
+ if (!options.allowPrototypes) {
591
+ return;
592
+ }
593
+ }
594
+
595
+ keys.push(segment[1]);
596
+ } // If there's a remainder, just add whatever is left
597
+
598
+
599
+ if (segment) {
600
+ keys.push('[' + key.slice(segment.index) + ']');
601
+ }
602
+
603
+ return parseObject(keys, val, options, valuesParsed);
604
+ };
605
+
606
+ var normalizeParseOptions = function normalizeParseOptions(opts) {
607
+ if (!opts) {
608
+ return defaults;
609
+ }
610
+
611
+ if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
612
+ throw new TypeError('Decoder has to be a function.');
613
+ }
614
+
615
+ if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
616
+ throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
617
+ }
618
+
619
+ var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
620
+ return {
621
+ allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
622
+ allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
623
+ arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
624
+ charset: charset,
625
+ charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
626
+ comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
627
+ decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
628
+ delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
629
+ // eslint-disable-next-line no-implicit-coercion, no-extra-parens
630
+ depth: typeof opts.depth === 'number' || opts.depth === false ? +opts.depth : defaults.depth,
631
+ ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
632
+ interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
633
+ parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
634
+ parseArrays: opts.parseArrays !== false,
635
+ plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
636
+ strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
637
+ };
638
+ };
639
+
640
+ module.exports = function (str, opts) {
641
+ var options = normalizeParseOptions(opts);
642
+
643
+ if (str === '' || str === null || typeof str === 'undefined') {
644
+ return options.plainObjects ? Object.create(null) : {};
645
+ }
646
+
647
+ var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
648
+ var obj = options.plainObjects ? Object.create(null) : {}; // Iterate over the keys and setup the new object
649
+
650
+ var keys = Object.keys(tempObj);
651
+
652
+ for (var i = 0; i < keys.length; ++i) {
653
+ var key = keys[i];
654
+ var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
655
+ obj = utils.merge(obj, newObj, options);
656
+ }
657
+
658
+ return utils.compact(obj);
659
+ };
660
+
661
+ },{"./utils":7}],6:[function(require,module,exports){
662
+ 'use strict';
663
+
664
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
665
+
666
+ var utils = require('./utils');
667
+
668
+ var formats = require('./formats');
669
+
670
+ var has = Object.prototype.hasOwnProperty;
671
+ var arrayPrefixGenerators = {
672
+ brackets: function brackets(prefix) {
673
+ return prefix + '[]';
674
+ },
675
+ comma: 'comma',
676
+ indices: function indices(prefix, key) {
677
+ return prefix + '[' + key + ']';
678
+ },
679
+ repeat: function repeat(prefix) {
680
+ return prefix;
681
+ }
682
+ };
683
+ var isArray = Array.isArray;
684
+ var push = Array.prototype.push;
685
+
686
+ var pushToArray = function pushToArray(arr, valueOrArray) {
687
+ push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
688
+ };
689
+
690
+ var toISO = Date.prototype.toISOString;
691
+ var defaultFormat = formats['default'];
692
+ var defaults = {
693
+ addQueryPrefix: false,
694
+ allowDots: false,
695
+ charset: 'utf-8',
696
+ charsetSentinel: false,
697
+ delimiter: '&',
698
+ encode: true,
699
+ encoder: utils.encode,
700
+ encodeValuesOnly: false,
701
+ format: defaultFormat,
702
+ formatter: formats.formatters[defaultFormat],
703
+ // deprecated
704
+ indices: false,
705
+ serializeDate: function serializeDate(date) {
706
+ return toISO.call(date);
707
+ },
708
+ skipNulls: false,
709
+ strictNullHandling: false
710
+ };
711
+
712
+ var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
713
+ return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || _typeof(v) === 'symbol' || typeof v === 'bigint';
714
+ };
715
+
716
+ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, formatter, encodeValuesOnly, charset) {
717
+ var obj = object;
718
+
719
+ if (typeof filter === 'function') {
720
+ obj = filter(prefix, obj);
721
+ } else if (obj instanceof Date) {
722
+ obj = serializeDate(obj);
723
+ } else if (generateArrayPrefix === 'comma' && isArray(obj)) {
724
+ obj = utils.maybeMap(obj, function (value) {
725
+ if (value instanceof Date) {
726
+ return serializeDate(value);
727
+ }
728
+
729
+ return value;
730
+ }).join(',');
731
+ }
732
+
733
+ if (obj === null) {
734
+ if (strictNullHandling) {
735
+ return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key') : prefix;
736
+ }
737
+
738
+ obj = '';
739
+ }
740
+
741
+ if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
742
+ if (encoder) {
743
+ var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key');
744
+ return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value'))];
745
+ }
746
+
747
+ return [formatter(prefix) + '=' + formatter(String(obj))];
748
+ }
749
+
750
+ var values = [];
751
+
752
+ if (typeof obj === 'undefined') {
753
+ return values;
754
+ }
755
+
756
+ var objKeys;
757
+
758
+ if (isArray(filter)) {
759
+ objKeys = filter;
760
+ } else {
761
+ var keys = Object.keys(obj);
762
+ objKeys = sort ? keys.sort(sort) : keys;
763
+ }
764
+
765
+ for (var i = 0; i < objKeys.length; ++i) {
766
+ var key = objKeys[i];
767
+ var value = obj[key];
768
+
769
+ if (skipNulls && value === null) {
770
+ continue;
771
+ }
772
+
773
+ var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix : prefix + (allowDots ? '.' + key : '[' + key + ']');
774
+ pushToArray(values, stringify(value, keyPrefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, formatter, encodeValuesOnly, charset));
775
+ }
776
+
777
+ return values;
778
+ };
779
+
780
+ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
781
+ if (!opts) {
782
+ return defaults;
783
+ }
784
+
785
+ if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
786
+ throw new TypeError('Encoder has to be a function.');
787
+ }
788
+
789
+ var charset = opts.charset || defaults.charset;
790
+
791
+ if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
792
+ throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
793
+ }
794
+
795
+ var format = formats['default'];
796
+
797
+ if (typeof opts.format !== 'undefined') {
798
+ if (!has.call(formats.formatters, opts.format)) {
799
+ throw new TypeError('Unknown format option provided.');
800
+ }
801
+
802
+ format = opts.format;
803
+ }
804
+
805
+ var formatter = formats.formatters[format];
806
+ var filter = defaults.filter;
807
+
808
+ if (typeof opts.filter === 'function' || isArray(opts.filter)) {
809
+ filter = opts.filter;
810
+ }
811
+
812
+ return {
813
+ addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
814
+ allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
815
+ charset: charset,
816
+ charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
817
+ delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
818
+ encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
819
+ encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
820
+ encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
821
+ filter: filter,
822
+ formatter: formatter,
823
+ serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,
824
+ skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,
825
+ sort: typeof opts.sort === 'function' ? opts.sort : null,
826
+ strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
827
+ };
828
+ };
829
+
830
+ module.exports = function (object, opts) {
831
+ var obj = object;
832
+ var options = normalizeStringifyOptions(opts);
833
+ var objKeys;
834
+ var filter;
835
+
836
+ if (typeof options.filter === 'function') {
837
+ filter = options.filter;
838
+ obj = filter('', obj);
839
+ } else if (isArray(options.filter)) {
840
+ filter = options.filter;
841
+ objKeys = filter;
842
+ }
843
+
844
+ var keys = [];
845
+
846
+ if (_typeof(obj) !== 'object' || obj === null) {
847
+ return '';
848
+ }
849
+
850
+ var arrayFormat;
851
+
852
+ if (opts && opts.arrayFormat in arrayPrefixGenerators) {
853
+ arrayFormat = opts.arrayFormat;
854
+ } else if (opts && 'indices' in opts) {
855
+ arrayFormat = opts.indices ? 'indices' : 'repeat';
856
+ } else {
857
+ arrayFormat = 'indices';
858
+ }
859
+
860
+ var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
861
+
862
+ if (!objKeys) {
863
+ objKeys = Object.keys(obj);
864
+ }
865
+
866
+ if (options.sort) {
867
+ objKeys.sort(options.sort);
868
+ }
869
+
870
+ for (var i = 0; i < objKeys.length; ++i) {
871
+ var key = objKeys[i];
872
+
873
+ if (options.skipNulls && obj[key] === null) {
874
+ continue;
875
+ }
876
+
877
+ pushToArray(keys, stringify(obj[key], key, generateArrayPrefix, options.strictNullHandling, options.skipNulls, options.encode ? options.encoder : null, options.filter, options.sort, options.allowDots, options.serializeDate, options.formatter, options.encodeValuesOnly, options.charset));
878
+ }
879
+
880
+ var joined = keys.join(options.delimiter);
881
+ var prefix = options.addQueryPrefix === true ? '?' : '';
882
+
883
+ if (options.charsetSentinel) {
884
+ if (options.charset === 'iso-8859-1') {
885
+ // encodeURIComponent('&#10003;'), the "numeric entity" representation of a checkmark
886
+ prefix += 'utf8=%26%2310003%3B&';
887
+ } else {
888
+ // encodeURIComponent('✓')
889
+ prefix += 'utf8=%E2%9C%93&';
890
+ }
891
+ }
892
+
893
+ return joined.length > 0 ? prefix + joined : '';
894
+ };
895
+
896
+ },{"./formats":3,"./utils":7}],7:[function(require,module,exports){
897
+ 'use strict';
898
+
899
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
900
+
901
+ var has = Object.prototype.hasOwnProperty;
902
+ var isArray = Array.isArray;
903
+
904
+ var hexTable = function () {
905
+ var array = [];
906
+
907
+ for (var i = 0; i < 256; ++i) {
908
+ array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
909
+ }
910
+
911
+ return array;
912
+ }();
913
+
914
+ var compactQueue = function compactQueue(queue) {
915
+ while (queue.length > 1) {
916
+ var item = queue.pop();
917
+ var obj = item.obj[item.prop];
918
+
919
+ if (isArray(obj)) {
920
+ var compacted = [];
921
+
922
+ for (var j = 0; j < obj.length; ++j) {
923
+ if (typeof obj[j] !== 'undefined') {
924
+ compacted.push(obj[j]);
925
+ }
926
+ }
927
+
928
+ item.obj[item.prop] = compacted;
929
+ }
930
+ }
931
+ };
932
+
933
+ var arrayToObject = function arrayToObject(source, options) {
934
+ var obj = options && options.plainObjects ? Object.create(null) : {};
935
+
936
+ for (var i = 0; i < source.length; ++i) {
937
+ if (typeof source[i] !== 'undefined') {
938
+ obj[i] = source[i];
939
+ }
940
+ }
941
+
942
+ return obj;
943
+ };
944
+
945
+ var merge = function merge(target, source, options) {
946
+ /* eslint no-param-reassign: 0 */
947
+ if (!source) {
948
+ return target;
949
+ }
950
+
951
+ if (_typeof(source) !== 'object') {
952
+ if (isArray(target)) {
953
+ target.push(source);
954
+ } else if (target && _typeof(target) === 'object') {
955
+ if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {
956
+ target[source] = true;
957
+ }
958
+ } else {
959
+ return [target, source];
960
+ }
961
+
962
+ return target;
963
+ }
964
+
965
+ if (!target || _typeof(target) !== 'object') {
966
+ return [target].concat(source);
967
+ }
968
+
969
+ var mergeTarget = target;
970
+
971
+ if (isArray(target) && !isArray(source)) {
972
+ mergeTarget = arrayToObject(target, options);
973
+ }
974
+
975
+ if (isArray(target) && isArray(source)) {
976
+ source.forEach(function (item, i) {
977
+ if (has.call(target, i)) {
978
+ var targetItem = target[i];
979
+
980
+ if (targetItem && _typeof(targetItem) === 'object' && item && _typeof(item) === 'object') {
981
+ target[i] = merge(targetItem, item, options);
982
+ } else {
983
+ target.push(item);
984
+ }
985
+ } else {
986
+ target[i] = item;
987
+ }
988
+ });
989
+ return target;
990
+ }
991
+
992
+ return Object.keys(source).reduce(function (acc, key) {
993
+ var value = source[key];
994
+
995
+ if (has.call(acc, key)) {
996
+ acc[key] = merge(acc[key], value, options);
997
+ } else {
998
+ acc[key] = value;
999
+ }
1000
+
1001
+ return acc;
1002
+ }, mergeTarget);
1003
+ };
1004
+
1005
+ var assign = function assignSingleSource(target, source) {
1006
+ return Object.keys(source).reduce(function (acc, key) {
1007
+ acc[key] = source[key];
1008
+ return acc;
1009
+ }, target);
1010
+ };
1011
+
1012
+ var decode = function decode(str, decoder, charset) {
1013
+ var strWithoutPlus = str.replace(/\+/g, ' ');
1014
+
1015
+ if (charset === 'iso-8859-1') {
1016
+ // unescape never throws, no try...catch needed:
1017
+ return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
1018
+ } // utf-8
1019
+
1020
+
1021
+ try {
1022
+ return decodeURIComponent(strWithoutPlus);
1023
+ } catch (e) {
1024
+ return strWithoutPlus;
1025
+ }
1026
+ };
1027
+
1028
+ var encode = function encode(str, defaultEncoder, charset) {
1029
+ // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
1030
+ // It has been adapted here for stricter adherence to RFC 3986
1031
+ if (str.length === 0) {
1032
+ return str;
1033
+ }
1034
+
1035
+ var string = str;
1036
+
1037
+ if (_typeof(str) === 'symbol') {
1038
+ string = Symbol.prototype.toString.call(str);
1039
+ } else if (typeof str !== 'string') {
1040
+ string = String(str);
1041
+ }
1042
+
1043
+ if (charset === 'iso-8859-1') {
1044
+ return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
1045
+ return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
1046
+ });
1047
+ }
1048
+
1049
+ var out = '';
1050
+
1051
+ for (var i = 0; i < string.length; ++i) {
1052
+ var c = string.charCodeAt(i);
1053
+
1054
+ if (c === 0x2D // -
1055
+ || c === 0x2E // .
1056
+ || c === 0x5F // _
1057
+ || c === 0x7E // ~
1058
+ || c >= 0x30 && c <= 0x39 // 0-9
1059
+ || c >= 0x41 && c <= 0x5A // a-z
1060
+ || c >= 0x61 && c <= 0x7A // A-Z
1061
+ ) {
1062
+ out += string.charAt(i);
1063
+ continue;
1064
+ }
1065
+
1066
+ if (c < 0x80) {
1067
+ out = out + hexTable[c];
1068
+ continue;
1069
+ }
1070
+
1071
+ if (c < 0x800) {
1072
+ out = out + (hexTable[0xC0 | c >> 6] + hexTable[0x80 | c & 0x3F]);
1073
+ continue;
1074
+ }
1075
+
1076
+ if (c < 0xD800 || c >= 0xE000) {
1077
+ out = out + (hexTable[0xE0 | c >> 12] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F]);
1078
+ continue;
1079
+ }
1080
+
1081
+ i += 1;
1082
+ c = 0x10000 + ((c & 0x3FF) << 10 | string.charCodeAt(i) & 0x3FF);
1083
+ out += hexTable[0xF0 | c >> 18] + hexTable[0x80 | c >> 12 & 0x3F] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F];
1084
+ }
1085
+
1086
+ return out;
1087
+ };
1088
+
1089
+ var compact = function compact(value) {
1090
+ var queue = [{
1091
+ obj: {
1092
+ o: value
1093
+ },
1094
+ prop: 'o'
1095
+ }];
1096
+ var refs = [];
1097
+
1098
+ for (var i = 0; i < queue.length; ++i) {
1099
+ var item = queue[i];
1100
+ var obj = item.obj[item.prop];
1101
+ var keys = Object.keys(obj);
1102
+
1103
+ for (var j = 0; j < keys.length; ++j) {
1104
+ var key = keys[j];
1105
+ var val = obj[key];
1106
+
1107
+ if (_typeof(val) === 'object' && val !== null && refs.indexOf(val) === -1) {
1108
+ queue.push({
1109
+ obj: obj,
1110
+ prop: key
1111
+ });
1112
+ refs.push(val);
1113
+ }
1114
+ }
1115
+ }
1116
+
1117
+ compactQueue(queue);
1118
+ return value;
1119
+ };
1120
+
1121
+ var isRegExp = function isRegExp(obj) {
1122
+ return Object.prototype.toString.call(obj) === '[object RegExp]';
1123
+ };
1124
+
1125
+ var isBuffer = function isBuffer(obj) {
1126
+ if (!obj || _typeof(obj) !== 'object') {
1127
+ return false;
1128
+ }
1129
+
1130
+ return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
1131
+ };
1132
+
1133
+ var combine = function combine(a, b) {
1134
+ return [].concat(a, b);
1135
+ };
1136
+
1137
+ var maybeMap = function maybeMap(val, fn) {
1138
+ if (isArray(val)) {
1139
+ var mapped = [];
1140
+
1141
+ for (var i = 0; i < val.length; i += 1) {
1142
+ mapped.push(fn(val[i]));
1143
+ }
1144
+
1145
+ return mapped;
1146
+ }
1147
+
1148
+ return fn(val);
1149
+ };
1150
+
1151
+ module.exports = {
1152
+ arrayToObject: arrayToObject,
1153
+ assign: assign,
1154
+ combine: combine,
1155
+ compact: compact,
1156
+ decode: decode,
1157
+ encode: encode,
1158
+ isBuffer: isBuffer,
1159
+ isRegExp: isRegExp,
1160
+ maybeMap: maybeMap,
1161
+ merge: merge
1162
+ };
1163
+
1164
+ },{}],8:[function(require,module,exports){
374
1165
  "use strict";
375
1166
 
376
1167
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -413,7 +1204,7 @@ Agent.prototype._setDefaults = function (req) {
413
1204
 
414
1205
  module.exports = Agent;
415
1206
 
416
- },{}],4:[function(require,module,exports){
1207
+ },{}],9:[function(require,module,exports){
417
1208
  "use strict";
418
1209
 
419
1210
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
@@ -431,7 +1222,7 @@ function isObject(obj) {
431
1222
 
432
1223
  module.exports = isObject;
433
1224
 
434
- },{}],5:[function(require,module,exports){
1225
+ },{}],10:[function(require,module,exports){
435
1226
  "use strict";
436
1227
 
437
1228
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
@@ -457,6 +1248,8 @@ var Emitter = require('component-emitter');
457
1248
 
458
1249
  var safeStringify = require('fast-safe-stringify');
459
1250
 
1251
+ var qs = require('qs');
1252
+
460
1253
  var RequestBase = require('./request-base');
461
1254
 
462
1255
  var isObject = require('./is-object');
@@ -645,7 +1438,7 @@ request.types = {
645
1438
  */
646
1439
 
647
1440
  request.serialize = {
648
- 'application/x-www-form-urlencoded': serialize,
1441
+ 'application/x-www-form-urlencoded': qs.stringify,
649
1442
  'application/json': safeStringify
650
1443
  };
651
1444
  /**
@@ -1452,7 +2245,7 @@ request.put = function (url, data, fn) {
1452
2245
  return req;
1453
2246
  };
1454
2247
 
1455
- },{"./agent-base":3,"./is-object":4,"./request-base":6,"./response-base":7,"component-emitter":1,"fast-safe-stringify":2}],6:[function(require,module,exports){
2248
+ },{"./agent-base":8,"./is-object":9,"./request-base":11,"./response-base":12,"component-emitter":1,"fast-safe-stringify":2,"qs":4}],11:[function(require,module,exports){
1456
2249
  "use strict";
1457
2250
 
1458
2251
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
@@ -2235,7 +3028,7 @@ RequestBase.prototype._setTimeouts = function () {
2235
3028
  }
2236
3029
  };
2237
3030
 
2238
- },{"./is-object":4}],7:[function(require,module,exports){
3031
+ },{"./is-object":9}],12:[function(require,module,exports){
2239
3032
  "use strict";
2240
3033
 
2241
3034
  /**
@@ -2367,7 +3160,7 @@ ResponseBase.prototype._setStatusProperties = function (status) {
2367
3160
  this.unprocessableEntity = status === 422;
2368
3161
  };
2369
3162
 
2370
- },{"./utils":8}],8:[function(require,module,exports){
3163
+ },{"./utils":13}],13:[function(require,module,exports){
2371
3164
  "use strict";
2372
3165
 
2373
3166
  function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
@@ -2473,5 +3266,5 @@ exports.cleanHeader = function (header, changesOrigin) {
2473
3266
  return header;
2474
3267
  };
2475
3268
 
2476
- },{}]},{},[5])(5)
3269
+ },{}]},{},[10])(10)
2477
3270
  });