@bigbinary/neeto-commons-frontend 2.0.2 → 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/README.md +1 -1
- package/initializers.cjs.js +21 -22
- package/initializers.js +21 -22
- package/package.json +2 -1
- package/pure.cjs.js +28 -11
- package/pure.d.ts +1 -0
- package/pure.js +28 -12
- package/react-utils.cjs.js +2 -3
- package/react-utils.js +2 -3
- package/utils.cjs.js +697 -0
- package/utils.d.ts +2 -0
- package/utils.js +698 -2
package/utils.cjs.js
CHANGED
|
@@ -29,6 +29,67 @@ var resetAuthTokens = function resetAuthTokens() {
|
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
function _arrayWithHoles(arr) {
|
|
33
|
+
if (Array.isArray(arr)) return arr;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function _iterableToArrayLimit(arr, i) {
|
|
37
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
38
|
+
|
|
39
|
+
if (_i == null) return;
|
|
40
|
+
var _arr = [];
|
|
41
|
+
var _n = true;
|
|
42
|
+
var _d = false;
|
|
43
|
+
|
|
44
|
+
var _s, _e;
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
48
|
+
_arr.push(_s.value);
|
|
49
|
+
|
|
50
|
+
if (i && _arr.length === i) break;
|
|
51
|
+
}
|
|
52
|
+
} catch (err) {
|
|
53
|
+
_d = true;
|
|
54
|
+
_e = err;
|
|
55
|
+
} finally {
|
|
56
|
+
try {
|
|
57
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
58
|
+
} finally {
|
|
59
|
+
if (_d) throw _e;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return _arr;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function _arrayLikeToArray(arr, len) {
|
|
67
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
68
|
+
|
|
69
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
70
|
+
arr2[i] = arr[i];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return arr2;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
77
|
+
if (!o) return;
|
|
78
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
79
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
80
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
81
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
82
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function _nonIterableRest() {
|
|
86
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function _slicedToArray(arr, i) {
|
|
90
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
91
|
+
}
|
|
92
|
+
|
|
32
93
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
33
94
|
try {
|
|
34
95
|
var info = gen[key](arg);
|
|
@@ -491,6 +552,626 @@ ramda.curry(function (x, y) {
|
|
|
491
552
|
});
|
|
492
553
|
ramda.complement(ramda.equals);
|
|
493
554
|
|
|
555
|
+
var queryString = {};
|
|
556
|
+
|
|
557
|
+
var strictUriEncode = str => encodeURIComponent(str).replace(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
558
|
+
|
|
559
|
+
var token = '%[a-f0-9]{2}';
|
|
560
|
+
var singleMatcher = new RegExp(token, 'gi');
|
|
561
|
+
var multiMatcher = new RegExp('(' + token + ')+', 'gi');
|
|
562
|
+
|
|
563
|
+
function decodeComponents(components, split) {
|
|
564
|
+
try {
|
|
565
|
+
// Try to decode the entire string first
|
|
566
|
+
return decodeURIComponent(components.join(''));
|
|
567
|
+
} catch (err) {
|
|
568
|
+
// Do nothing
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
if (components.length === 1) {
|
|
572
|
+
return components;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
split = split || 1;
|
|
576
|
+
|
|
577
|
+
// Split the array in 2 parts
|
|
578
|
+
var left = components.slice(0, split);
|
|
579
|
+
var right = components.slice(split);
|
|
580
|
+
|
|
581
|
+
return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
function decode(input) {
|
|
585
|
+
try {
|
|
586
|
+
return decodeURIComponent(input);
|
|
587
|
+
} catch (err) {
|
|
588
|
+
var tokens = input.match(singleMatcher);
|
|
589
|
+
|
|
590
|
+
for (var i = 1; i < tokens.length; i++) {
|
|
591
|
+
input = decodeComponents(tokens, i).join('');
|
|
592
|
+
|
|
593
|
+
tokens = input.match(singleMatcher);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
return input;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
function customDecodeURIComponent(input) {
|
|
601
|
+
// Keep track of all the replacements and prefill the map with the `BOM`
|
|
602
|
+
var replaceMap = {
|
|
603
|
+
'%FE%FF': '\uFFFD\uFFFD',
|
|
604
|
+
'%FF%FE': '\uFFFD\uFFFD'
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
var match = multiMatcher.exec(input);
|
|
608
|
+
while (match) {
|
|
609
|
+
try {
|
|
610
|
+
// Decode as big chunks as possible
|
|
611
|
+
replaceMap[match[0]] = decodeURIComponent(match[0]);
|
|
612
|
+
} catch (err) {
|
|
613
|
+
var result = decode(match[0]);
|
|
614
|
+
|
|
615
|
+
if (result !== match[0]) {
|
|
616
|
+
replaceMap[match[0]] = result;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
match = multiMatcher.exec(input);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
// Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else
|
|
624
|
+
replaceMap['%C2'] = '\uFFFD';
|
|
625
|
+
|
|
626
|
+
var entries = Object.keys(replaceMap);
|
|
627
|
+
|
|
628
|
+
for (var i = 0; i < entries.length; i++) {
|
|
629
|
+
// Replace all decoded components
|
|
630
|
+
var key = entries[i];
|
|
631
|
+
input = input.replace(new RegExp(key, 'g'), replaceMap[key]);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
return input;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
var decodeUriComponent = function (encodedURI) {
|
|
638
|
+
if (typeof encodedURI !== 'string') {
|
|
639
|
+
throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`');
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
try {
|
|
643
|
+
encodedURI = encodedURI.replace(/\+/g, ' ');
|
|
644
|
+
|
|
645
|
+
// Try the built in decoder first
|
|
646
|
+
return decodeURIComponent(encodedURI);
|
|
647
|
+
} catch (err) {
|
|
648
|
+
// Fallback to a more advanced decoder
|
|
649
|
+
return customDecodeURIComponent(encodedURI);
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
var splitOnFirst = (string, separator) => {
|
|
654
|
+
if (!(typeof string === 'string' && typeof separator === 'string')) {
|
|
655
|
+
throw new TypeError('Expected the arguments to be of type `string`');
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if (separator === '') {
|
|
659
|
+
return [string];
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
const separatorIndex = string.indexOf(separator);
|
|
663
|
+
|
|
664
|
+
if (separatorIndex === -1) {
|
|
665
|
+
return [string];
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
return [
|
|
669
|
+
string.slice(0, separatorIndex),
|
|
670
|
+
string.slice(separatorIndex + separator.length)
|
|
671
|
+
];
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
var filterObj = function (obj, predicate) {
|
|
675
|
+
var ret = {};
|
|
676
|
+
var keys = Object.keys(obj);
|
|
677
|
+
var isArr = Array.isArray(predicate);
|
|
678
|
+
|
|
679
|
+
for (var i = 0; i < keys.length; i++) {
|
|
680
|
+
var key = keys[i];
|
|
681
|
+
var val = obj[key];
|
|
682
|
+
|
|
683
|
+
if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) {
|
|
684
|
+
ret[key] = val;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
return ret;
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
(function (exports) {
|
|
692
|
+
const strictUriEncode$1 = strictUriEncode;
|
|
693
|
+
const decodeComponent = decodeUriComponent;
|
|
694
|
+
const splitOnFirst$1 = splitOnFirst;
|
|
695
|
+
const filterObject = filterObj;
|
|
696
|
+
|
|
697
|
+
const isNullOrUndefined = value => value === null || value === undefined;
|
|
698
|
+
|
|
699
|
+
const encodeFragmentIdentifier = Symbol('encodeFragmentIdentifier');
|
|
700
|
+
|
|
701
|
+
function encoderForArrayFormat(options) {
|
|
702
|
+
switch (options.arrayFormat) {
|
|
703
|
+
case 'index':
|
|
704
|
+
return key => (result, value) => {
|
|
705
|
+
const index = result.length;
|
|
706
|
+
|
|
707
|
+
if (
|
|
708
|
+
value === undefined ||
|
|
709
|
+
(options.skipNull && value === null) ||
|
|
710
|
+
(options.skipEmptyString && value === '')
|
|
711
|
+
) {
|
|
712
|
+
return result;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
if (value === null) {
|
|
716
|
+
return [...result, [encode(key, options), '[', index, ']'].join('')];
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
return [
|
|
720
|
+
...result,
|
|
721
|
+
[encode(key, options), '[', encode(index, options), ']=', encode(value, options)].join('')
|
|
722
|
+
];
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
case 'bracket':
|
|
726
|
+
return key => (result, value) => {
|
|
727
|
+
if (
|
|
728
|
+
value === undefined ||
|
|
729
|
+
(options.skipNull && value === null) ||
|
|
730
|
+
(options.skipEmptyString && value === '')
|
|
731
|
+
) {
|
|
732
|
+
return result;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
if (value === null) {
|
|
736
|
+
return [...result, [encode(key, options), '[]'].join('')];
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
return [...result, [encode(key, options), '[]=', encode(value, options)].join('')];
|
|
740
|
+
};
|
|
741
|
+
|
|
742
|
+
case 'colon-list-separator':
|
|
743
|
+
return key => (result, value) => {
|
|
744
|
+
if (
|
|
745
|
+
value === undefined ||
|
|
746
|
+
(options.skipNull && value === null) ||
|
|
747
|
+
(options.skipEmptyString && value === '')
|
|
748
|
+
) {
|
|
749
|
+
return result;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
if (value === null) {
|
|
753
|
+
return [...result, [encode(key, options), ':list='].join('')];
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
return [...result, [encode(key, options), ':list=', encode(value, options)].join('')];
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
case 'comma':
|
|
760
|
+
case 'separator':
|
|
761
|
+
case 'bracket-separator': {
|
|
762
|
+
const keyValueSep = options.arrayFormat === 'bracket-separator' ?
|
|
763
|
+
'[]=' :
|
|
764
|
+
'=';
|
|
765
|
+
|
|
766
|
+
return key => (result, value) => {
|
|
767
|
+
if (
|
|
768
|
+
value === undefined ||
|
|
769
|
+
(options.skipNull && value === null) ||
|
|
770
|
+
(options.skipEmptyString && value === '')
|
|
771
|
+
) {
|
|
772
|
+
return result;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
// Translate null to an empty string so that it doesn't serialize as 'null'
|
|
776
|
+
value = value === null ? '' : value;
|
|
777
|
+
|
|
778
|
+
if (result.length === 0) {
|
|
779
|
+
return [[encode(key, options), keyValueSep, encode(value, options)].join('')];
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
default:
|
|
787
|
+
return key => (result, value) => {
|
|
788
|
+
if (
|
|
789
|
+
value === undefined ||
|
|
790
|
+
(options.skipNull && value === null) ||
|
|
791
|
+
(options.skipEmptyString && value === '')
|
|
792
|
+
) {
|
|
793
|
+
return result;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
if (value === null) {
|
|
797
|
+
return [...result, encode(key, options)];
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
return [...result, [encode(key, options), '=', encode(value, options)].join('')];
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
function parserForArrayFormat(options) {
|
|
806
|
+
let result;
|
|
807
|
+
|
|
808
|
+
switch (options.arrayFormat) {
|
|
809
|
+
case 'index':
|
|
810
|
+
return (key, value, accumulator) => {
|
|
811
|
+
result = /\[(\d*)\]$/.exec(key);
|
|
812
|
+
|
|
813
|
+
key = key.replace(/\[\d*\]$/, '');
|
|
814
|
+
|
|
815
|
+
if (!result) {
|
|
816
|
+
accumulator[key] = value;
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
if (accumulator[key] === undefined) {
|
|
821
|
+
accumulator[key] = {};
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
accumulator[key][result[1]] = value;
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
case 'bracket':
|
|
828
|
+
return (key, value, accumulator) => {
|
|
829
|
+
result = /(\[\])$/.exec(key);
|
|
830
|
+
key = key.replace(/\[\]$/, '');
|
|
831
|
+
|
|
832
|
+
if (!result) {
|
|
833
|
+
accumulator[key] = value;
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
if (accumulator[key] === undefined) {
|
|
838
|
+
accumulator[key] = [value];
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
case 'colon-list-separator':
|
|
846
|
+
return (key, value, accumulator) => {
|
|
847
|
+
result = /(:list)$/.exec(key);
|
|
848
|
+
key = key.replace(/:list$/, '');
|
|
849
|
+
|
|
850
|
+
if (!result) {
|
|
851
|
+
accumulator[key] = value;
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
if (accumulator[key] === undefined) {
|
|
856
|
+
accumulator[key] = [value];
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
case 'comma':
|
|
864
|
+
case 'separator':
|
|
865
|
+
return (key, value, accumulator) => {
|
|
866
|
+
const isArray = typeof value === 'string' && value.includes(options.arrayFormatSeparator);
|
|
867
|
+
const isEncodedArray = (typeof value === 'string' && !isArray && decode(value, options).includes(options.arrayFormatSeparator));
|
|
868
|
+
value = isEncodedArray ? decode(value, options) : value;
|
|
869
|
+
const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options);
|
|
870
|
+
accumulator[key] = newValue;
|
|
871
|
+
};
|
|
872
|
+
|
|
873
|
+
case 'bracket-separator':
|
|
874
|
+
return (key, value, accumulator) => {
|
|
875
|
+
const isArray = /(\[\])$/.test(key);
|
|
876
|
+
key = key.replace(/\[\]$/, '');
|
|
877
|
+
|
|
878
|
+
if (!isArray) {
|
|
879
|
+
accumulator[key] = value ? decode(value, options) : value;
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
const arrayValue = value === null ?
|
|
884
|
+
[] :
|
|
885
|
+
value.split(options.arrayFormatSeparator).map(item => decode(item, options));
|
|
886
|
+
|
|
887
|
+
if (accumulator[key] === undefined) {
|
|
888
|
+
accumulator[key] = arrayValue;
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
accumulator[key] = [].concat(accumulator[key], arrayValue);
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
default:
|
|
896
|
+
return (key, value, accumulator) => {
|
|
897
|
+
if (accumulator[key] === undefined) {
|
|
898
|
+
accumulator[key] = value;
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
function validateArrayFormatSeparator(value) {
|
|
908
|
+
if (typeof value !== 'string' || value.length !== 1) {
|
|
909
|
+
throw new TypeError('arrayFormatSeparator must be single character string');
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
function encode(value, options) {
|
|
914
|
+
if (options.encode) {
|
|
915
|
+
return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
return value;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
function decode(value, options) {
|
|
922
|
+
if (options.decode) {
|
|
923
|
+
return decodeComponent(value);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
return value;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
function keysSorter(input) {
|
|
930
|
+
if (Array.isArray(input)) {
|
|
931
|
+
return input.sort();
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
if (typeof input === 'object') {
|
|
935
|
+
return keysSorter(Object.keys(input))
|
|
936
|
+
.sort((a, b) => Number(a) - Number(b))
|
|
937
|
+
.map(key => input[key]);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
return input;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
function removeHash(input) {
|
|
944
|
+
const hashStart = input.indexOf('#');
|
|
945
|
+
if (hashStart !== -1) {
|
|
946
|
+
input = input.slice(0, hashStart);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
return input;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
function getHash(url) {
|
|
953
|
+
let hash = '';
|
|
954
|
+
const hashStart = url.indexOf('#');
|
|
955
|
+
if (hashStart !== -1) {
|
|
956
|
+
hash = url.slice(hashStart);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
return hash;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
function extract(input) {
|
|
963
|
+
input = removeHash(input);
|
|
964
|
+
const queryStart = input.indexOf('?');
|
|
965
|
+
if (queryStart === -1) {
|
|
966
|
+
return '';
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
return input.slice(queryStart + 1);
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
function parseValue(value, options) {
|
|
973
|
+
if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {
|
|
974
|
+
value = Number(value);
|
|
975
|
+
} else if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
|
|
976
|
+
value = value.toLowerCase() === 'true';
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
return value;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
function parse(query, options) {
|
|
983
|
+
options = Object.assign({
|
|
984
|
+
decode: true,
|
|
985
|
+
sort: true,
|
|
986
|
+
arrayFormat: 'none',
|
|
987
|
+
arrayFormatSeparator: ',',
|
|
988
|
+
parseNumbers: false,
|
|
989
|
+
parseBooleans: false
|
|
990
|
+
}, options);
|
|
991
|
+
|
|
992
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
993
|
+
|
|
994
|
+
const formatter = parserForArrayFormat(options);
|
|
995
|
+
|
|
996
|
+
// Create an object with no prototype
|
|
997
|
+
const ret = Object.create(null);
|
|
998
|
+
|
|
999
|
+
if (typeof query !== 'string') {
|
|
1000
|
+
return ret;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
query = query.trim().replace(/^[?#&]/, '');
|
|
1004
|
+
|
|
1005
|
+
if (!query) {
|
|
1006
|
+
return ret;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
for (const param of query.split('&')) {
|
|
1010
|
+
if (param === '') {
|
|
1011
|
+
continue;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, ' ') : param, '=');
|
|
1015
|
+
|
|
1016
|
+
// Missing `=` should be `null`:
|
|
1017
|
+
// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
|
|
1018
|
+
value = value === undefined ? null : ['comma', 'separator', 'bracket-separator'].includes(options.arrayFormat) ? value : decode(value, options);
|
|
1019
|
+
formatter(decode(key, options), value, ret);
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
for (const key of Object.keys(ret)) {
|
|
1023
|
+
const value = ret[key];
|
|
1024
|
+
if (typeof value === 'object' && value !== null) {
|
|
1025
|
+
for (const k of Object.keys(value)) {
|
|
1026
|
+
value[k] = parseValue(value[k], options);
|
|
1027
|
+
}
|
|
1028
|
+
} else {
|
|
1029
|
+
ret[key] = parseValue(value, options);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
if (options.sort === false) {
|
|
1034
|
+
return ret;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
|
|
1038
|
+
const value = ret[key];
|
|
1039
|
+
if (Boolean(value) && typeof value === 'object' && !Array.isArray(value)) {
|
|
1040
|
+
// Sort object keys, not values
|
|
1041
|
+
result[key] = keysSorter(value);
|
|
1042
|
+
} else {
|
|
1043
|
+
result[key] = value;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
return result;
|
|
1047
|
+
}, Object.create(null));
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
exports.extract = extract;
|
|
1051
|
+
exports.parse = parse;
|
|
1052
|
+
|
|
1053
|
+
exports.stringify = (object, options) => {
|
|
1054
|
+
if (!object) {
|
|
1055
|
+
return '';
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
options = Object.assign({
|
|
1059
|
+
encode: true,
|
|
1060
|
+
strict: true,
|
|
1061
|
+
arrayFormat: 'none',
|
|
1062
|
+
arrayFormatSeparator: ','
|
|
1063
|
+
}, options);
|
|
1064
|
+
|
|
1065
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
1066
|
+
|
|
1067
|
+
const shouldFilter = key => (
|
|
1068
|
+
(options.skipNull && isNullOrUndefined(object[key])) ||
|
|
1069
|
+
(options.skipEmptyString && object[key] === '')
|
|
1070
|
+
);
|
|
1071
|
+
|
|
1072
|
+
const formatter = encoderForArrayFormat(options);
|
|
1073
|
+
|
|
1074
|
+
const objectCopy = {};
|
|
1075
|
+
|
|
1076
|
+
for (const key of Object.keys(object)) {
|
|
1077
|
+
if (!shouldFilter(key)) {
|
|
1078
|
+
objectCopy[key] = object[key];
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
const keys = Object.keys(objectCopy);
|
|
1083
|
+
|
|
1084
|
+
if (options.sort !== false) {
|
|
1085
|
+
keys.sort(options.sort);
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
return keys.map(key => {
|
|
1089
|
+
const value = object[key];
|
|
1090
|
+
|
|
1091
|
+
if (value === undefined) {
|
|
1092
|
+
return '';
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
if (value === null) {
|
|
1096
|
+
return encode(key, options);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
if (Array.isArray(value)) {
|
|
1100
|
+
if (value.length === 0 && options.arrayFormat === 'bracket-separator') {
|
|
1101
|
+
return encode(key, options) + '[]';
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
return value
|
|
1105
|
+
.reduce(formatter(key), [])
|
|
1106
|
+
.join('&');
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
return encode(key, options) + '=' + encode(value, options);
|
|
1110
|
+
}).filter(x => x.length > 0).join('&');
|
|
1111
|
+
};
|
|
1112
|
+
|
|
1113
|
+
exports.parseUrl = (url, options) => {
|
|
1114
|
+
options = Object.assign({
|
|
1115
|
+
decode: true
|
|
1116
|
+
}, options);
|
|
1117
|
+
|
|
1118
|
+
const [url_, hash] = splitOnFirst$1(url, '#');
|
|
1119
|
+
|
|
1120
|
+
return Object.assign(
|
|
1121
|
+
{
|
|
1122
|
+
url: url_.split('?')[0] || '',
|
|
1123
|
+
query: parse(extract(url), options)
|
|
1124
|
+
},
|
|
1125
|
+
options && options.parseFragmentIdentifier && hash ? {fragmentIdentifier: decode(hash, options)} : {}
|
|
1126
|
+
);
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1129
|
+
exports.stringifyUrl = (object, options) => {
|
|
1130
|
+
options = Object.assign({
|
|
1131
|
+
encode: true,
|
|
1132
|
+
strict: true,
|
|
1133
|
+
[encodeFragmentIdentifier]: true
|
|
1134
|
+
}, options);
|
|
1135
|
+
|
|
1136
|
+
const url = removeHash(object.url).split('?')[0] || '';
|
|
1137
|
+
const queryFromUrl = exports.extract(object.url);
|
|
1138
|
+
const parsedQueryFromUrl = exports.parse(queryFromUrl, {sort: false});
|
|
1139
|
+
|
|
1140
|
+
const query = Object.assign(parsedQueryFromUrl, object.query);
|
|
1141
|
+
let queryString = exports.stringify(query, options);
|
|
1142
|
+
if (queryString) {
|
|
1143
|
+
queryString = `?${queryString}`;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
let hash = getHash(object.url);
|
|
1147
|
+
if (object.fragmentIdentifier) {
|
|
1148
|
+
hash = `#${options[encodeFragmentIdentifier] ? encode(object.fragmentIdentifier, options) : object.fragmentIdentifier}`;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
return `${url}${queryString}${hash}`;
|
|
1152
|
+
};
|
|
1153
|
+
|
|
1154
|
+
exports.pick = (input, filter, options) => {
|
|
1155
|
+
options = Object.assign({
|
|
1156
|
+
parseFragmentIdentifier: true,
|
|
1157
|
+
[encodeFragmentIdentifier]: false
|
|
1158
|
+
}, options);
|
|
1159
|
+
|
|
1160
|
+
const {url, query, fragmentIdentifier} = exports.parseUrl(input, options);
|
|
1161
|
+
return exports.stringifyUrl({
|
|
1162
|
+
url,
|
|
1163
|
+
query: filterObject(query, filter),
|
|
1164
|
+
fragmentIdentifier
|
|
1165
|
+
}, options);
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1168
|
+
exports.exclude = (input, filter, options) => {
|
|
1169
|
+
const exclusionFilter = Array.isArray(filter) ? key => !filter.includes(key) : (key, value) => !filter(key, value);
|
|
1170
|
+
|
|
1171
|
+
return exports.pick(input, exclusionFilter, options);
|
|
1172
|
+
};
|
|
1173
|
+
} (queryString));
|
|
1174
|
+
|
|
494
1175
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
495
1176
|
|
|
496
1177
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -586,6 +1267,21 @@ var copyToClipboard = /*#__PURE__*/function () {
|
|
|
586
1267
|
return _ref.apply(this, arguments);
|
|
587
1268
|
};
|
|
588
1269
|
}();
|
|
1270
|
+
var buildUrl = function buildUrl(route, params) {
|
|
1271
|
+
var placeHolders = [];
|
|
1272
|
+
ramda.toPairs(params).forEach(function (_ref3) {
|
|
1273
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
1274
|
+
key = _ref4[0],
|
|
1275
|
+
value = _ref4[1];
|
|
1276
|
+
|
|
1277
|
+
if (route.includes(":".concat(key))) {
|
|
1278
|
+
placeHolders.push(key);
|
|
1279
|
+
route = route.replace(":".concat(key), encodeURIComponent(value));
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
var queryParams = ramda.omit(placeHolders, params);
|
|
1283
|
+
return ramda.isEmpty(queryParams) ? route : "".concat(route, "?").concat(queryString.stringify(queryParams));
|
|
1284
|
+
};
|
|
589
1285
|
|
|
590
1286
|
dayjs__default["default"].extend(relativeTime__default["default"]);
|
|
591
1287
|
dayjs__default["default"].extend(updateLocale__default["default"]);
|
|
@@ -619,6 +1315,7 @@ var timeFormat = {
|
|
|
619
1315
|
};
|
|
620
1316
|
var dateFormat = timeFormat;
|
|
621
1317
|
|
|
1318
|
+
exports.buildUrl = buildUrl;
|
|
622
1319
|
exports.copyToClipboard = copyToClipboard;
|
|
623
1320
|
exports.dateFormat = dateFormat;
|
|
624
1321
|
exports.getSubdomain = getSubdomain;
|