@koine/utils 1.0.26 → 1.0.29
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/{async.d.ts → Defer.d.ts} +5 -5
- package/{async.js → Defer.js} +2 -7
- package/{emitter.d.ts → Emitter.d.ts} +1 -0
- package/{emitter.js → Emitter.js} +1 -0
- package/accentSets.d.ts +16 -0
- package/accentSets.js +38 -0
- package/addOrReplaceAtIdx.d.ts +5 -0
- package/addOrReplaceAtIdx.js +19 -0
- package/arrayToLookup.d.ts +7 -0
- package/arrayToLookup.js +13 -0
- package/buildUrlQueryString.d.ts +12 -0
- package/buildUrlQueryString.js +24 -0
- package/changeUrlPath.d.ts +10 -0
- package/changeUrlPath.js +18 -0
- package/chunkByChunks.d.ts +7 -0
- package/chunkByChunks.js +37 -0
- package/chunkBySize.d.ts +6 -0
- package/chunkBySize.js +12 -0
- package/clamp.d.ts +8 -0
- package/clamp.js +10 -0
- package/clsx.d.ts +9 -0
- package/clsx.js +49 -0
- package/convertRange.d.ts +14 -0
- package/convertRange.js +16 -0
- package/cookie.d.ts +7 -26
- package/cookie.js +3 -221
- package/decode.d.ts +6 -0
- package/decode.js +10 -0
- package/encode.d.ts +6 -0
- package/encode.js +10 -0
- package/{cast.d.ts → ensureInt.d.ts} +3 -1
- package/{cast.js → ensureInt.js} +3 -4
- package/findDuplicatedIndexes.d.ts +5 -0
- package/findDuplicatedIndexes.js +14 -0
- package/getKeys.d.ts +9 -0
- package/getKeys.js +9 -0
- package/getNonce.d.ts +6 -0
- package/getNonce.js +9 -0
- package/getType.d.ts +22 -0
- package/getType.js +19 -0
- package/getUrlHashParams.d.ts +9 -0
- package/getUrlHashParams.js +16 -0
- package/getUrlHashPathname.d.ts +9 -0
- package/getUrlHashPathname.js +13 -0
- package/getUrlPathnameParts.d.ts +12 -0
- package/getUrlPathnameParts.js +20 -0
- package/getUrlQueryParams.d.ts +14 -0
- package/getUrlQueryParams.js +38 -0
- package/index.d.ts +107 -15
- package/index.js +108 -16
- package/isAnyObject.d.ts +8 -0
- package/isAnyObject.js +10 -0
- package/isArray.d.ts +7 -0
- package/isArray.js +10 -0
- package/isBlob.d.ts +7 -0
- package/isBlob.js +10 -0
- package/isBoolean.d.ts +7 -0
- package/isBoolean.js +10 -0
- package/isBrowser.d.ts +6 -0
- package/{ssr.js → isBrowser.js} +5 -2
- package/isDate.d.ts +7 -0
- package/isDate.js +10 -0
- package/isEmptyArray.d.ts +7 -0
- package/isEmptyArray.js +10 -0
- package/isEmptyObject.d.ts +9 -0
- package/isEmptyObject.js +10 -0
- package/isEmptyString.d.ts +7 -0
- package/isEmptyString.js +9 -0
- package/isError.d.ts +7 -0
- package/isError.js +10 -0
- package/isExternalUrl.d.ts +9 -0
- package/isExternalUrl.js +21 -0
- package/isFile.d.ts +7 -0
- package/isFile.js +10 -0
- package/isFloat.d.ts +7 -0
- package/isFloat.js +10 -0
- package/isFormData.d.ts +7 -0
- package/isFormData.js +10 -0
- package/isFullArray.d.ts +7 -0
- package/isFullArray.js +10 -0
- package/isFullObject.d.ts +8 -0
- package/isFullObject.js +10 -0
- package/isFullString.d.ts +7 -0
- package/isFullString.js +10 -0
- package/isFunction.d.ts +8 -0
- package/isFunction.js +9 -0
- package/{detect.d.ts → isIE.d.ts} +3 -4
- package/isIE.js +18 -0
- package/isInt.d.ts +7 -0
- package/isInt.js +10 -0
- package/isMap.d.ts +7 -0
- package/isMap.js +10 -0
- package/isMobile.d.ts +7 -0
- package/{detect.js → isMobile.js} +4 -15
- package/isNaNValue.d.ts +7 -0
- package/isNaNValue.js +10 -0
- package/isNegativeNumber.d.ts +7 -0
- package/isNegativeNumber.js +10 -0
- package/isNull.d.ts +7 -0
- package/isNull.js +10 -0
- package/isNullOrUndefined.d.ts +7 -0
- package/isNullOrUndefined.js +10 -0
- package/isNumber.d.ts +9 -0
- package/isNumber.js +12 -0
- package/isObject.d.ts +8 -0
- package/isObject.js +10 -0
- package/isObjectLike.d.ts +10 -0
- package/isObjectLike.js +12 -0
- package/isOneOf.d.ts +9 -0
- package/isOneOf.js +10 -0
- package/isPlainObject.d.ts +8 -0
- package/isPlainObject.js +13 -0
- package/isPositiveNumber.d.ts +7 -0
- package/isPositiveNumber.js +10 -0
- package/isPrimitive.d.ts +7 -0
- package/isPrimitive.js +20 -0
- package/isPromise.d.ts +7 -0
- package/isPromise.js +10 -0
- package/isRegExp.d.ts +7 -0
- package/isRegExp.js +10 -0
- package/isServer.d.ts +6 -0
- package/isServer.js +8 -0
- package/isSet.d.ts +7 -0
- package/isSet.js +10 -0
- package/isString.d.ts +7 -0
- package/isString.js +10 -0
- package/isSymbol.d.ts +7 -0
- package/isSymbol.js +10 -0
- package/isType.d.ts +11 -0
- package/isType.js +22 -0
- package/isUndefined.d.ts +7 -0
- package/isUndefined.js +10 -0
- package/isWeakMap.d.ts +7 -0
- package/isWeakMap.js +10 -0
- package/isWeakSet.d.ts +7 -0
- package/isWeakSet.js +10 -0
- package/location.d.ts +2 -145
- package/location.js +1 -299
- package/mapListBy.d.ts +7 -0
- package/mapListBy.js +14 -0
- package/{match-sorter.d.ts → matchSorter.d.ts} +1 -0
- package/{match-sorter.js → matchSorter.js} +2 -1
- package/mergeObjects.d.ts +7 -0
- package/{objects.js → mergeObjects.js} +2 -31
- package/mergeUrlQueryParams.d.ts +9 -0
- package/mergeUrlQueryParams.js +22 -0
- package/navigateToHashParams.d.ts +9 -0
- package/navigateToHashParams.js +22 -0
- package/navigateToMergedHashParams.d.ts +8 -0
- package/navigateToMergedHashParams.js +14 -0
- package/navigateToMergedParams.d.ts +9 -0
- package/navigateToMergedParams.js +14 -0
- package/navigateToParams.d.ts +10 -0
- package/navigateToParams.js +18 -0
- package/navigateWithoutUrlParam.d.ts +8 -0
- package/navigateWithoutUrlParam.js +19 -0
- package/node/{async.js → Defer.js} +3 -9
- package/node/{emitter.js → Emitter.js} +1 -0
- package/node/accentSets.js +41 -0
- package/node/addOrReplaceAtIdx.js +23 -0
- package/node/arrayToLookup.js +17 -0
- package/node/buildUrlQueryString.js +28 -0
- package/node/changeUrlPath.js +22 -0
- package/node/chunkByChunks.js +41 -0
- package/node/chunkBySize.js +16 -0
- package/node/clamp.js +14 -0
- package/node/clsx.js +53 -0
- package/node/convertRange.js +20 -0
- package/node/cookie.js +4 -227
- package/node/decode.js +14 -0
- package/node/encode.js +14 -0
- package/node/{cast.js → ensureInt.js} +4 -6
- package/node/findDuplicatedIndexes.js +18 -0
- package/node/getKeys.js +12 -0
- package/node/getNonce.js +13 -0
- package/node/getType.js +23 -0
- package/node/getUrlHashParams.js +20 -0
- package/node/getUrlHashPathname.js +17 -0
- package/node/getUrlPathnameParts.js +24 -0
- package/node/getUrlQueryParams.js +42 -0
- package/node/index.js +108 -16
- package/node/isAnyObject.js +14 -0
- package/node/isArray.js +14 -0
- package/node/isBlob.js +14 -0
- package/node/isBoolean.js +14 -0
- package/node/{ssr.js → isBrowser.js} +6 -3
- package/node/isDate.js +14 -0
- package/node/isEmptyArray.js +14 -0
- package/node/isEmptyObject.js +14 -0
- package/node/isEmptyString.js +13 -0
- package/node/isError.js +14 -0
- package/node/isExternalUrl.js +25 -0
- package/node/isFile.js +14 -0
- package/node/isFloat.js +14 -0
- package/node/isFormData.js +14 -0
- package/node/isFullArray.js +14 -0
- package/node/isFullObject.js +14 -0
- package/node/isFullString.js +14 -0
- package/node/isFunction.js +13 -0
- package/node/isIE.js +22 -0
- package/node/isInt.js +14 -0
- package/node/isMap.js +14 -0
- package/node/{detect.js → isMobile.js} +6 -18
- package/node/isNaNValue.js +14 -0
- package/node/isNegativeNumber.js +14 -0
- package/node/isNull.js +14 -0
- package/node/isNullOrUndefined.js +13 -0
- package/node/isNumber.js +16 -0
- package/node/isObject.js +14 -0
- package/node/isObjectLike.js +16 -0
- package/node/isOneOf.js +14 -0
- package/node/isPlainObject.js +17 -0
- package/node/isPositiveNumber.js +14 -0
- package/node/isPrimitive.js +24 -0
- package/node/isPromise.js +14 -0
- package/node/isRegExp.js +14 -0
- package/node/isServer.js +11 -0
- package/node/isSet.js +14 -0
- package/node/isString.js +14 -0
- package/node/isSymbol.js +14 -0
- package/node/isType.js +26 -0
- package/node/isUndefined.js +14 -0
- package/node/isWeakMap.js +14 -0
- package/node/isWeakSet.js +14 -0
- package/node/location.js +0 -321
- package/node/mapListBy.js +18 -0
- package/node/{match-sorter.js → matchSorter.js} +3 -2
- package/node/{objects.js → mergeObjects.js} +5 -36
- package/node/mergeUrlQueryParams.js +26 -0
- package/node/navigateToHashParams.js +26 -0
- package/node/navigateToMergedHashParams.js +18 -0
- package/node/navigateToMergedParams.js +18 -0
- package/node/navigateToParams.js +22 -0
- package/node/navigateWithoutUrlParam.js +23 -0
- package/node/normaliseUrl.js +18 -0
- package/node/normaliseUrlPathname.js +18 -0
- package/node/{analytics-google.js → pageview.js} +12 -10
- package/node/parseCookie.js +52 -0
- package/node/parseURL.js +24 -0
- package/node/randomInt.js +13 -0
- package/node/{misc.js → randomKey.js} +2 -0
- package/node/readCookie.js +38 -0
- package/node/redirectTo.js +19 -0
- package/node/removeAccents.js +19 -0
- package/node/removeCookie.js +19 -0
- package/node/removeDuplicatesByKey.js +25 -0
- package/node/removeDuplicatesComparing.js +14 -0
- package/node/removeIndexesFromArray.js +18 -0
- package/node/removeTrailingSlash.js +14 -0
- package/node/{math.js → roundTo.js} +3 -32
- package/node/serializeCookie.js +108 -0
- package/node/setCookie.js +61 -0
- package/node/shuffle.js +36 -0
- package/node/slugify.js +27 -0
- package/node/swapMap.js +18 -0
- package/node/{typography.js → titleCase.js} +3 -12
- package/node/toNumber.js +12 -0
- package/node/{colors.js → toRgba.js} +4 -0
- package/node/transformToUrlPathname.js +20 -0
- package/node/truncate.js +17 -0
- package/node/uid.js +4 -13
- package/node/updateLinkParams.js +18 -0
- package/node/updateUrlQueryParams.js +22 -0
- package/node/uuid.js +17 -0
- package/node/wait.js +13 -0
- package/node/whitelistObject.js +19 -0
- package/normaliseUrl.d.ts +10 -0
- package/normaliseUrl.js +14 -0
- package/normaliseUrlPathname.d.ts +10 -0
- package/normaliseUrlPathname.js +14 -0
- package/package.json +1 -1
- package/{analytics-google.d.ts → pageview.d.ts} +3 -0
- package/{analytics-google.js → pageview.js} +12 -10
- package/parseCookie.d.ts +11 -0
- package/parseCookie.js +48 -0
- package/parseURL.d.ts +17 -0
- package/parseURL.js +20 -0
- package/randomInt.d.ts +7 -0
- package/randomInt.js +9 -0
- package/{misc.d.ts → randomKey.d.ts} +2 -0
- package/{misc.js → randomKey.js} +2 -0
- package/readCookie.d.ts +3 -0
- package/readCookie.js +34 -0
- package/redirectTo.d.ts +9 -0
- package/redirectTo.js +15 -0
- package/removeAccents.d.ts +6 -0
- package/removeAccents.js +15 -0
- package/removeCookie.d.ts +10 -0
- package/removeCookie.js +15 -0
- package/removeDuplicatesByKey.d.ts +8 -0
- package/removeDuplicatesByKey.js +21 -0
- package/removeDuplicatesComparing.d.ts +5 -0
- package/removeDuplicatesComparing.js +10 -0
- package/removeIndexesFromArray.d.ts +5 -0
- package/removeIndexesFromArray.js +14 -0
- package/removeTrailingSlash.d.ts +7 -0
- package/removeTrailingSlash.js +10 -0
- package/roundTo.d.ts +8 -0
- package/{math.js → roundTo.js} +2 -28
- package/serializeCookie.d.ts +27 -0
- package/serializeCookie.js +104 -0
- package/setCookie.d.ts +10 -0
- package/setCookie.js +57 -0
- package/shuffle.d.ts +16 -0
- package/shuffle.js +32 -0
- package/{text.d.ts → slugify.d.ts} +2 -5
- package/slugify.js +23 -0
- package/swapMap.d.ts +7 -0
- package/swapMap.js +14 -0
- package/{typography.d.ts → titleCase.d.ts} +2 -4
- package/{typography.js → titleCase.js} +2 -10
- package/toNumber.d.ts +5 -0
- package/toNumber.js +8 -0
- package/{colors.d.ts → toRgba.d.ts} +4 -0
- package/{colors.js → toRgba.js} +4 -0
- package/transformToUrlPathname.d.ts +11 -0
- package/transformToUrlPathname.js +16 -0
- package/truncate.d.ts +7 -0
- package/truncate.js +13 -0
- package/uid.d.ts +3 -6
- package/uid.js +3 -11
- package/updateLinkParams.d.ts +10 -0
- package/updateLinkParams.js +14 -0
- package/updateUrlQueryParams.d.ts +9 -0
- package/updateUrlQueryParams.js +18 -0
- package/uuid.d.ts +8 -0
- package/uuid.js +13 -0
- package/wait.d.ts +7 -0
- package/wait.js +9 -0
- package/whitelistObject.d.ts +8 -0
- package/whitelistObject.js +15 -0
- package/arrays.d.ts +0 -41
- package/arrays.js +0 -153
- package/is.d.ts +0 -288
- package/is.js +0 -376
- package/math.d.ts +0 -28
- package/node/arrays.js +0 -166
- package/node/is.js +0 -417
- package/node/security.js +0 -29
- package/node/text.js +0 -70
- package/objects.d.ts +0 -22
- package/security.d.ts +0 -12
- package/security.js +0 -23
- package/ssr.d.ts +0 -2
- package/text.js +0 -65
package/node/location.js
CHANGED
|
@@ -1,323 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUrlHashPathname = exports.getUrlHashParams = exports.navigateToMergedHashParams = exports.navigateToHashParams = exports.isExternalUrl = exports.redirectTo = exports.updateLinkParams = exports.updateUrlQueryParams = exports.mergeUrlQueryParams = exports.navigateWithoutUrlParam = exports.navigateToMergedParams = exports.navigateToParams = exports.changeUrlPath = exports.buildUrlQueryString = exports.getUrlPathnameParts = exports.getUrlQueryParams = exports.transformToUrlPathname = exports.normaliseUrlPathname = exports.normaliseUrl = exports.removeTralingSlash = exports.parseURL = void 0;
|
|
4
|
-
var ssr_1 = require("./ssr");
|
|
5
|
-
var is_1 = require("./is");
|
|
6
|
-
/**
|
|
7
|
-
* Solution without DOM or specific env native methods
|
|
8
|
-
*
|
|
9
|
-
* @see https://stackoverflow.com/a/21553982/1938970
|
|
10
|
-
*/
|
|
11
|
-
function parseURL(url) {
|
|
12
|
-
var match = url.match(/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
13
|
-
return (match && {
|
|
14
|
-
href: url,
|
|
15
|
-
protocol: match[1],
|
|
16
|
-
host: match[2],
|
|
17
|
-
hostname: match[3],
|
|
18
|
-
port: match[4],
|
|
19
|
-
pathname: match[5],
|
|
20
|
-
search: match[6],
|
|
21
|
-
hash: match[7],
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
exports.parseURL = parseURL;
|
|
25
|
-
/**
|
|
26
|
-
* Strips out the trailing slash
|
|
27
|
-
*/
|
|
28
|
-
function removeTralingSlash(urlLike) {
|
|
29
|
-
if (urlLike === void 0) { urlLike = ""; }
|
|
30
|
-
return urlLike.replace(/\/*$/, "");
|
|
31
|
-
}
|
|
32
|
-
exports.removeTralingSlash = removeTralingSlash;
|
|
33
|
-
/**
|
|
34
|
-
* Normalise URL (absolute URL)
|
|
35
|
-
*
|
|
36
|
-
* - replaces too many consecutive slashes (except `http{s}://`)
|
|
37
|
-
* - removes the trailing slash
|
|
38
|
-
*/
|
|
39
|
-
function normaliseUrl(absoluteUrl) {
|
|
40
|
-
if (absoluteUrl === void 0) { absoluteUrl = ""; }
|
|
41
|
-
return removeTralingSlash(absoluteUrl.replace(/([^:]\/)\/+/g, "$1"));
|
|
42
|
-
}
|
|
43
|
-
exports.normaliseUrl = normaliseUrl;
|
|
44
|
-
/**
|
|
45
|
-
* Normalise URL pathname (relative URL)
|
|
46
|
-
*
|
|
47
|
-
* - replaces too many consecutive slashes
|
|
48
|
-
* - removes the trailing slash
|
|
49
|
-
*/
|
|
50
|
-
function normaliseUrlPathname(pathname) {
|
|
51
|
-
if (pathname === void 0) { pathname = ""; }
|
|
52
|
-
return removeTralingSlash(pathname.replace(/\/+/g, "/"));
|
|
53
|
-
}
|
|
54
|
-
exports.normaliseUrlPathname = normaliseUrlPathname;
|
|
55
|
-
/**
|
|
56
|
-
* Transform string in a URL pathname (relative URL)
|
|
57
|
-
*
|
|
58
|
-
* - adds an initial slash
|
|
59
|
-
* - encode the string
|
|
60
|
-
* - replaces whitespaces with dashes
|
|
61
|
-
*/
|
|
62
|
-
function transformToUrlPathname(toPathname) {
|
|
63
|
-
return (0, is_1.isString)(toPathname)
|
|
64
|
-
? "/".concat(encodeURIComponent(toPathname.replace(/\s/g, "-").toLowerCase()))
|
|
65
|
-
: "";
|
|
66
|
-
}
|
|
67
|
-
exports.transformToUrlPathname = transformToUrlPathname;
|
|
68
|
-
/**
|
|
69
|
-
* Get parsed query parameters as object dictionary (from URL or given query string)
|
|
70
|
-
*
|
|
71
|
-
* @param url A URL which contains a `?`, e.g. `?myparam=x` or `https://a.com?myparams=x`.
|
|
72
|
-
* If not provided it defaults reading the current URL query string with
|
|
73
|
-
* `location.search`. Through this argument you can use this
|
|
74
|
-
* same function to parse, for instance, the query params of
|
|
75
|
-
* the `href` of a `<a href="...">` HTML tag.
|
|
76
|
-
*
|
|
77
|
-
*/
|
|
78
|
-
function getUrlQueryParams(url) {
|
|
79
|
-
var _a;
|
|
80
|
-
var params = {};
|
|
81
|
-
var search = url
|
|
82
|
-
? (_a = url.split("?")) === null || _a === void 0 ? void 0 : _a[1]
|
|
83
|
-
: ssr_1.isBrowser
|
|
84
|
-
? location.search.substring(1)
|
|
85
|
-
: "";
|
|
86
|
-
if (!search) {
|
|
87
|
-
return {};
|
|
88
|
-
}
|
|
89
|
-
try {
|
|
90
|
-
// @see https://stackoverflow.com/a/8649003/1938970
|
|
91
|
-
var paramsAsObj = "{\"".concat(search
|
|
92
|
-
.replace(/&/g, '","')
|
|
93
|
-
.replace(/=/g, '":"'), "\"}");
|
|
94
|
-
params = JSON.parse(paramsAsObj, function (key, value) {
|
|
95
|
-
return key === "" ? value : decodeURIComponent(value);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
catch (e) {
|
|
99
|
-
// do nothing or warn on process.env["NODE_ENV"] !== "production"
|
|
100
|
-
}
|
|
101
|
-
return params;
|
|
102
|
-
}
|
|
103
|
-
exports.getUrlQueryParams = getUrlQueryParams;
|
|
104
|
-
/**
|
|
105
|
-
* Get pathname parts
|
|
106
|
-
*
|
|
107
|
-
* First clean the pathname from the first slash if any then split the pathname
|
|
108
|
-
* in parts,
|
|
109
|
-
* Given a pathname like: `"/en/{prefix}/{collection}/{slug}"` we obtain
|
|
110
|
-
* `[locale, prefix, collection, slug]`
|
|
111
|
-
*/
|
|
112
|
-
function getUrlPathnameParts(pathname) {
|
|
113
|
-
if (pathname === void 0) { pathname = ""; }
|
|
114
|
-
pathname = pathname || ssr_1.isBrowser ? location.pathname : "";
|
|
115
|
-
return pathname
|
|
116
|
-
.replace(/^\//, "")
|
|
117
|
-
.split("/")
|
|
118
|
-
.filter(function (part) { return part; });
|
|
119
|
-
}
|
|
120
|
-
exports.getUrlPathnameParts = getUrlPathnameParts;
|
|
121
|
-
/**
|
|
122
|
-
* Get clean query string for URL
|
|
123
|
-
*
|
|
124
|
-
* It returns the query string **with** the initial `?`
|
|
125
|
-
*
|
|
126
|
-
* TODO: at some point replace with `URLSearchParams`, @see [caniuse](https://caniuse.com/?search=URLSearchParams)
|
|
127
|
-
*/
|
|
128
|
-
function buildUrlQueryString(params) {
|
|
129
|
-
if (params === void 0) { params = {}; }
|
|
130
|
-
var output = "";
|
|
131
|
-
for (var key in params) {
|
|
132
|
-
var value = params[key];
|
|
133
|
-
if (!(0, is_1.isNull)(value) && !(0, is_1.isUndefined)(value)) {
|
|
134
|
-
output += "".concat(key, "=").concat(encodeURIComponent(value + ""), "&");
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
// removes the last &
|
|
138
|
-
return output ? "?".concat(output.replace(/&+$/, "")) : "";
|
|
139
|
-
}
|
|
140
|
-
exports.buildUrlQueryString = buildUrlQueryString;
|
|
141
|
-
/**
|
|
142
|
-
* Change URL path, ensures initial and ending slashes and normalise eventual
|
|
143
|
-
* consecutive slashes, it uses `history`.
|
|
144
|
-
*
|
|
145
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
146
|
-
* @returns {string} The new cleaned pathname
|
|
147
|
-
*/
|
|
148
|
-
function changeUrlPath(pathname, state, replace) {
|
|
149
|
-
var path = normaliseUrlPathname("/".concat(pathname, "/"));
|
|
150
|
-
if (ssr_1.isBrowser) {
|
|
151
|
-
history[replace ? "replaceState" : "pushState"](state, "", path);
|
|
152
|
-
}
|
|
153
|
-
return path;
|
|
154
|
-
}
|
|
155
|
-
exports.changeUrlPath = changeUrlPath;
|
|
156
|
-
/**
|
|
157
|
-
* Change current URL query parameters, it uses `history`.
|
|
158
|
-
*
|
|
159
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
160
|
-
* @returns The query string with initial `?`
|
|
161
|
-
*/
|
|
162
|
-
function navigateToParams(params, replace) {
|
|
163
|
-
if (params === void 0) { params = {}; }
|
|
164
|
-
var queryString = typeof params === "string" ? params : buildUrlQueryString(params);
|
|
165
|
-
if (ssr_1.isBrowser) {
|
|
166
|
-
history[replace ? "replaceState" : "pushState"](null, "", location.pathname + queryString);
|
|
167
|
-
}
|
|
168
|
-
return queryString;
|
|
169
|
-
}
|
|
170
|
-
exports.navigateToParams = navigateToParams;
|
|
171
|
-
/**
|
|
172
|
-
* Merge current URL query parameters with the given ones, it uses `history`.
|
|
173
|
-
*
|
|
174
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
175
|
-
*/
|
|
176
|
-
function navigateToMergedParams(params, replace) {
|
|
177
|
-
if (params === void 0) { params = {}; }
|
|
178
|
-
return navigateToParams(mergeUrlQueryParams(getUrlQueryParams(), params), replace);
|
|
179
|
-
}
|
|
180
|
-
exports.navigateToMergedParams = navigateToMergedParams;
|
|
181
|
-
/**
|
|
182
|
-
* Remove URL query parameter, it uses `history`
|
|
183
|
-
*
|
|
184
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
185
|
-
*/
|
|
186
|
-
function navigateWithoutUrlParam(paramName, replace) {
|
|
187
|
-
var params = {};
|
|
188
|
-
var currentParams = getUrlQueryParams();
|
|
189
|
-
for (var key in currentParams) {
|
|
190
|
-
if (key !== paramName) {
|
|
191
|
-
params[key] = currentParams[key];
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return navigateToParams(params, replace);
|
|
195
|
-
}
|
|
196
|
-
exports.navigateWithoutUrlParam = navigateWithoutUrlParam;
|
|
197
|
-
/**
|
|
198
|
-
* Merge query parameters objects, it *mutates* the first given object argument
|
|
199
|
-
*
|
|
200
|
-
* @pure
|
|
201
|
-
*/
|
|
202
|
-
function mergeUrlQueryParams(oldParams, newParams) {
|
|
203
|
-
if (oldParams === void 0) { oldParams = {}; }
|
|
204
|
-
if (newParams === void 0) { newParams = {}; }
|
|
205
|
-
for (var key in newParams) {
|
|
206
|
-
var value = newParams[key];
|
|
207
|
-
if (oldParams[key] && (0, is_1.isNull)(value)) {
|
|
208
|
-
delete oldParams[key];
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
oldParams[key] = value;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return oldParams;
|
|
215
|
-
}
|
|
216
|
-
exports.mergeUrlQueryParams = mergeUrlQueryParams;
|
|
217
|
-
/**
|
|
218
|
-
* Update a URL string query parameters merging the given new query parameters
|
|
219
|
-
*
|
|
220
|
-
* @pure
|
|
221
|
-
*/
|
|
222
|
-
function updateUrlQueryParams(url, newParams) {
|
|
223
|
-
if (newParams === void 0) { newParams = {}; }
|
|
224
|
-
var parts = url.split("?");
|
|
225
|
-
var allParams = parts[1]
|
|
226
|
-
? mergeUrlQueryParams(getUrlQueryParams(url), newParams)
|
|
227
|
-
: newParams;
|
|
228
|
-
return parts[0] + buildUrlQueryString(allParams);
|
|
229
|
-
}
|
|
230
|
-
exports.updateUrlQueryParams = updateUrlQueryParams;
|
|
231
|
-
/**
|
|
232
|
-
* Update link `<a href="">` merging the given new query parameters.
|
|
233
|
-
* it returns the newly created `href` URL value
|
|
234
|
-
*
|
|
235
|
-
* @pure
|
|
236
|
-
*/
|
|
237
|
-
function updateLinkParams($anchor, newParams) {
|
|
238
|
-
var href = updateUrlQueryParams($anchor.href, newParams);
|
|
239
|
-
$anchor.href = href;
|
|
240
|
-
return href;
|
|
241
|
-
}
|
|
242
|
-
exports.updateLinkParams = updateLinkParams;
|
|
243
|
-
/**
|
|
244
|
-
* Redirect to url with params {optionally}, removes eventual trailing question
|
|
245
|
-
* marks from the given URL, it uses `location`
|
|
246
|
-
*/
|
|
247
|
-
function redirectTo(url, params) {
|
|
248
|
-
if (ssr_1.isBrowser) {
|
|
249
|
-
var queryString = buildUrlQueryString(params);
|
|
250
|
-
location.href = url.replace(/\?+$/g, "") + queryString;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
exports.redirectTo = redirectTo;
|
|
254
|
-
/**
|
|
255
|
-
* Is external url compared to the given current URL (if not provided it falls
|
|
256
|
-
* back to `location.href`)
|
|
257
|
-
*
|
|
258
|
-
*/
|
|
259
|
-
function isExternalUrl(url, currentUrl) {
|
|
260
|
-
var _a;
|
|
261
|
-
var reg = /https?:\/\/((?:[\w\d-]+\.)+[\w\d]{2,})/i;
|
|
262
|
-
var urlMatches = reg.exec(url);
|
|
263
|
-
// if no matches are found it means we either have an invalid URL, a relative
|
|
264
|
-
// URL or a hash link, and those are not considered externals
|
|
265
|
-
if (!urlMatches) {
|
|
266
|
-
return false;
|
|
267
|
-
}
|
|
268
|
-
currentUrl = currentUrl || ssr_1.isBrowser ? location.href : "";
|
|
269
|
-
return currentUrl ? ((_a = reg.exec(currentUrl)) === null || _a === void 0 ? void 0 : _a[1]) !== urlMatches[1] : true;
|
|
270
|
-
}
|
|
271
|
-
exports.isExternalUrl = isExternalUrl;
|
|
272
|
-
/**
|
|
273
|
-
* It updates the `location.hash` with the given query params, it uses `location.hash`
|
|
274
|
-
* if a second argument `hash` is not provded
|
|
275
|
-
*/
|
|
276
|
-
function navigateToHashParams(params, hash) {
|
|
277
|
-
if (params === void 0) { params = {}; }
|
|
278
|
-
if (hash === void 0) { hash = ""; }
|
|
279
|
-
var useLocation = !hash;
|
|
280
|
-
hash = hash || location.hash;
|
|
281
|
-
var hashQueryLess = getUrlHashPathname(hash);
|
|
282
|
-
var queryString = typeof params === "string" ? params : buildUrlQueryString(params);
|
|
283
|
-
var newHash = "#/" + hashQueryLess + queryString;
|
|
284
|
-
if (useLocation) {
|
|
285
|
-
location.hash = newHash;
|
|
286
|
-
}
|
|
287
|
-
return newHash;
|
|
288
|
-
}
|
|
289
|
-
exports.navigateToHashParams = navigateToHashParams;
|
|
290
|
-
/**
|
|
291
|
-
* It updates the "query params" within the `location.hash`, it uses `location`
|
|
292
|
-
*/
|
|
293
|
-
function navigateToMergedHashParams(params, hash) {
|
|
294
|
-
if (params === void 0) { params = {}; }
|
|
295
|
-
if (hash === void 0) { hash = ""; }
|
|
296
|
-
return navigateToHashParams(mergeUrlQueryParams(getUrlHashParams(hash), params), hash);
|
|
297
|
-
}
|
|
298
|
-
exports.navigateToMergedHashParams = navigateToMergedHashParams;
|
|
299
|
-
/**
|
|
300
|
-
* It returns the "query params" as an object extracting it from the given `hash`
|
|
301
|
-
*string or, if not provided, failling back reading the `location.hash`
|
|
302
|
-
*/
|
|
303
|
-
function getUrlHashParams(hash) {
|
|
304
|
-
if (hash === void 0) { hash = ""; }
|
|
305
|
-
hash = hash || location.hash;
|
|
306
|
-
var hashParts = hash.split("?");
|
|
307
|
-
if (hashParts.length >= 1) {
|
|
308
|
-
return Object.fromEntries(new URLSearchParams(hashParts[1]));
|
|
309
|
-
}
|
|
310
|
-
return {};
|
|
311
|
-
}
|
|
312
|
-
exports.getUrlHashParams = getUrlHashParams;
|
|
313
|
-
/**
|
|
314
|
-
* It returns the "pathname" cleaned up from the `#` and the initial slashes
|
|
315
|
-
* extracting it from the given `hash` string or, if not provided, failling
|
|
316
|
-
* back reading the `location.hash`
|
|
317
|
-
*/
|
|
318
|
-
function getUrlHashPathname(hash) {
|
|
319
|
-
if (hash === void 0) { hash = ""; }
|
|
320
|
-
hash = hash || location.hash;
|
|
321
|
-
return hash.split("?")[0].replace(/^#\//, "");
|
|
322
|
-
}
|
|
323
|
-
exports.getUrlHashPathname = getUrlHashPathname;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapListBy = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Maps an array of objects into a map keyed with the given key
|
|
6
|
+
*
|
|
7
|
+
* @category array
|
|
8
|
+
*/
|
|
9
|
+
function mapListBy(array, key) {
|
|
10
|
+
if (array === void 0) { array = []; }
|
|
11
|
+
if (key === void 0) { key = ""; }
|
|
12
|
+
return array.reduce(function (obj, item) {
|
|
13
|
+
obj[item[key]] = item;
|
|
14
|
+
return obj;
|
|
15
|
+
}, {});
|
|
16
|
+
}
|
|
17
|
+
exports.mapListBy = mapListBy;
|
|
18
|
+
exports.default = mapListBy;
|
|
@@ -18,7 +18,7 @@ var tslib_1 = require("tslib");
|
|
|
18
18
|
* @copyright (c) 2020 Kent C. Dodds
|
|
19
19
|
* @author Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)
|
|
20
20
|
*/
|
|
21
|
-
var
|
|
21
|
+
var removeAccents_1 = require("./removeAccents");
|
|
22
22
|
var RANKING_CASE_SENSITIVE_EQUAL = 7;
|
|
23
23
|
var RANKING_EQUAL = 6;
|
|
24
24
|
var RANKING_STARTS_WITH = 5;
|
|
@@ -255,7 +255,7 @@ function prepareValueForComparison(value, _a) {
|
|
|
255
255
|
// so part of preparing the value for comparison is ensure that it is a string
|
|
256
256
|
value = "".concat(value); // toString
|
|
257
257
|
if (!keepDiacritics) {
|
|
258
|
-
value = (0,
|
|
258
|
+
value = (0, removeAccents_1.default)(value);
|
|
259
259
|
}
|
|
260
260
|
return value;
|
|
261
261
|
}
|
|
@@ -371,3 +371,4 @@ function getKeyAttributes(key) {
|
|
|
371
371
|
}
|
|
372
372
|
return tslib_1.__assign(tslib_1.__assign({}, defaultKeyAttributes), key);
|
|
373
373
|
}
|
|
374
|
+
exports.default = matchSorter;
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.mergeObjects = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var
|
|
6
|
-
/**
|
|
7
|
-
* Type safe replacement for `Object.keys(myObject)` to iterate over a record
|
|
8
|
-
* without loosing the key's types in simple `string`s.
|
|
9
|
-
*
|
|
10
|
-
* @see https://stackoverflow.com/a/59459000/1938970
|
|
11
|
-
*/
|
|
12
|
-
exports.getKeys = Object.keys;
|
|
5
|
+
var isObject_1 = require("./isObject");
|
|
13
6
|
/**
|
|
14
7
|
* Merge two or more objects together. It mutates the target object.
|
|
15
8
|
*
|
|
9
|
+
* @category objects
|
|
16
10
|
* @see https://stackoverflow.com/a/46973278/1938970
|
|
17
11
|
*/
|
|
18
12
|
var mergeObjects = function (target) {
|
|
@@ -27,10 +21,10 @@ var mergeObjects = function (target) {
|
|
|
27
21
|
if (source === undefined) {
|
|
28
22
|
return target;
|
|
29
23
|
}
|
|
30
|
-
if ((0,
|
|
24
|
+
if ((0, isObject_1.isObject)(target) && (0, isObject_1.isObject)(source)) {
|
|
31
25
|
Object.keys(source).forEach(function (_key) {
|
|
32
26
|
var key = _key;
|
|
33
|
-
if ((0,
|
|
27
|
+
if ((0, isObject_1.isObject)(source[key])) {
|
|
34
28
|
if (!target[key]) {
|
|
35
29
|
// @ts-expect-error FIXME: ...
|
|
36
30
|
target[key] = {};
|
|
@@ -45,28 +39,3 @@ var mergeObjects = function (target) {
|
|
|
45
39
|
return exports.mergeObjects.apply(void 0, tslib_1.__spreadArray([target], sources, false));
|
|
46
40
|
};
|
|
47
41
|
exports.mergeObjects = mergeObjects;
|
|
48
|
-
/**
|
|
49
|
-
* Swap object map key/value
|
|
50
|
-
*/
|
|
51
|
-
function swapMap(map) {
|
|
52
|
-
if (map === void 0) { map = {}; }
|
|
53
|
-
var output = {};
|
|
54
|
-
for (var key in map) {
|
|
55
|
-
output[map[key]] = key;
|
|
56
|
-
}
|
|
57
|
-
return output;
|
|
58
|
-
}
|
|
59
|
-
exports.swapMap = swapMap;
|
|
60
|
-
/**
|
|
61
|
-
* Whitelist an object properties by selecting only the given keys, it returns a
|
|
62
|
-
* new object.
|
|
63
|
-
*/
|
|
64
|
-
function whitelistObject(object, keys) {
|
|
65
|
-
var output = {};
|
|
66
|
-
var len = keys.length;
|
|
67
|
-
while (len--) {
|
|
68
|
-
output[keys[len]] = object[keys[len]];
|
|
69
|
-
}
|
|
70
|
-
return output;
|
|
71
|
-
}
|
|
72
|
-
exports.whitelistObject = whitelistObject;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeUrlQueryParams = void 0;
|
|
4
|
+
var isNull_1 = require("./isNull");
|
|
5
|
+
/**
|
|
6
|
+
* Merge query parameters objects, it *mutates* the first given object argument
|
|
7
|
+
*
|
|
8
|
+
* @category location
|
|
9
|
+
* @pure
|
|
10
|
+
*/
|
|
11
|
+
function mergeUrlQueryParams(oldParams, newParams) {
|
|
12
|
+
if (oldParams === void 0) { oldParams = {}; }
|
|
13
|
+
if (newParams === void 0) { newParams = {}; }
|
|
14
|
+
for (var key in newParams) {
|
|
15
|
+
var value = newParams[key];
|
|
16
|
+
if (oldParams[key] && (0, isNull_1.default)(value)) {
|
|
17
|
+
delete oldParams[key];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
oldParams[key] = value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return oldParams;
|
|
24
|
+
}
|
|
25
|
+
exports.mergeUrlQueryParams = mergeUrlQueryParams;
|
|
26
|
+
exports.default = mergeUrlQueryParams;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigateToHashParams = void 0;
|
|
4
|
+
var buildUrlQueryString_1 = require("./buildUrlQueryString");
|
|
5
|
+
var getUrlHashPathname_1 = require("./getUrlHashPathname");
|
|
6
|
+
/**
|
|
7
|
+
* It updates the `location.hash` with the given query params, it uses `location.hash`
|
|
8
|
+
* if a second argument `hash` is not provded
|
|
9
|
+
*
|
|
10
|
+
* @category location
|
|
11
|
+
*/
|
|
12
|
+
function navigateToHashParams(params, hash) {
|
|
13
|
+
if (params === void 0) { params = {}; }
|
|
14
|
+
if (hash === void 0) { hash = ""; }
|
|
15
|
+
var useLocation = !hash;
|
|
16
|
+
hash = hash || location.hash;
|
|
17
|
+
var hashQueryLess = (0, getUrlHashPathname_1.default)(hash);
|
|
18
|
+
var queryString = typeof params === "string" ? params : (0, buildUrlQueryString_1.default)(params);
|
|
19
|
+
var newHash = "#/" + hashQueryLess + queryString;
|
|
20
|
+
if (useLocation) {
|
|
21
|
+
location.hash = newHash;
|
|
22
|
+
}
|
|
23
|
+
return newHash;
|
|
24
|
+
}
|
|
25
|
+
exports.navigateToHashParams = navigateToHashParams;
|
|
26
|
+
exports.default = navigateToHashParams;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigateToMergedHashParams = void 0;
|
|
4
|
+
var getUrlHashParams_1 = require("./getUrlHashParams");
|
|
5
|
+
var mergeUrlQueryParams_1 = require("./mergeUrlQueryParams");
|
|
6
|
+
var navigateToHashParams_1 = require("./navigateToHashParams");
|
|
7
|
+
/**
|
|
8
|
+
* It updates the "query params" within the `location.hash`, it uses `location`
|
|
9
|
+
*
|
|
10
|
+
* @category location
|
|
11
|
+
*/
|
|
12
|
+
function navigateToMergedHashParams(params, hash) {
|
|
13
|
+
if (params === void 0) { params = {}; }
|
|
14
|
+
if (hash === void 0) { hash = ""; }
|
|
15
|
+
return (0, navigateToHashParams_1.default)((0, mergeUrlQueryParams_1.default)((0, getUrlHashParams_1.default)(hash), params), hash);
|
|
16
|
+
}
|
|
17
|
+
exports.navigateToMergedHashParams = navigateToMergedHashParams;
|
|
18
|
+
exports.default = navigateToMergedHashParams;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigateToMergedParams = void 0;
|
|
4
|
+
var getUrlQueryParams_1 = require("./getUrlQueryParams");
|
|
5
|
+
var mergeUrlQueryParams_1 = require("./mergeUrlQueryParams");
|
|
6
|
+
var navigateToParams_1 = require("./navigateToParams");
|
|
7
|
+
/**
|
|
8
|
+
* Merge current URL query parameters with the given ones, it uses `history`.
|
|
9
|
+
*
|
|
10
|
+
* @category location
|
|
11
|
+
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
12
|
+
*/
|
|
13
|
+
function navigateToMergedParams(params, replace) {
|
|
14
|
+
if (params === void 0) { params = {}; }
|
|
15
|
+
return (0, navigateToParams_1.default)((0, mergeUrlQueryParams_1.default)((0, getUrlQueryParams_1.default)(), params), replace);
|
|
16
|
+
}
|
|
17
|
+
exports.navigateToMergedParams = navigateToMergedParams;
|
|
18
|
+
exports.default = navigateToMergedParams;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigateToParams = void 0;
|
|
4
|
+
var buildUrlQueryString_1 = require("./buildUrlQueryString");
|
|
5
|
+
var isBrowser_1 = require("./isBrowser");
|
|
6
|
+
/**
|
|
7
|
+
* Change current URL query parameters, it uses `history`.
|
|
8
|
+
*
|
|
9
|
+
* @category location
|
|
10
|
+
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
11
|
+
* @returns The query string with initial `?`
|
|
12
|
+
*/
|
|
13
|
+
function navigateToParams(params, replace) {
|
|
14
|
+
if (params === void 0) { params = {}; }
|
|
15
|
+
var queryString = typeof params === "string" ? params : (0, buildUrlQueryString_1.default)(params);
|
|
16
|
+
if (isBrowser_1.default) {
|
|
17
|
+
history[replace ? "replaceState" : "pushState"](null, "", location.pathname + queryString);
|
|
18
|
+
}
|
|
19
|
+
return queryString;
|
|
20
|
+
}
|
|
21
|
+
exports.navigateToParams = navigateToParams;
|
|
22
|
+
exports.default = navigateToParams;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigateWithoutUrlParam = void 0;
|
|
4
|
+
var getUrlQueryParams_1 = require("./getUrlQueryParams");
|
|
5
|
+
var navigateToParams_1 = require("./navigateToParams");
|
|
6
|
+
/**
|
|
7
|
+
* Remove URL query parameter, it uses `history`
|
|
8
|
+
*
|
|
9
|
+
* @category location
|
|
10
|
+
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
11
|
+
*/
|
|
12
|
+
function navigateWithoutUrlParam(paramName, replace) {
|
|
13
|
+
var params = {};
|
|
14
|
+
var currentParams = (0, getUrlQueryParams_1.default)();
|
|
15
|
+
for (var key in currentParams) {
|
|
16
|
+
if (key !== paramName) {
|
|
17
|
+
params[key] = currentParams[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return (0, navigateToParams_1.default)(params, replace);
|
|
21
|
+
}
|
|
22
|
+
exports.navigateWithoutUrlParam = navigateWithoutUrlParam;
|
|
23
|
+
exports.default = navigateWithoutUrlParam;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normaliseUrl = void 0;
|
|
4
|
+
var removeTrailingSlash_1 = require("./removeTrailingSlash");
|
|
5
|
+
/**
|
|
6
|
+
* Normalise URL (absolute URL)
|
|
7
|
+
*
|
|
8
|
+
* - replaces too many consecutive slashes (except `http{s}://`)
|
|
9
|
+
* - removes the trailing slash
|
|
10
|
+
*
|
|
11
|
+
* @category location
|
|
12
|
+
*/
|
|
13
|
+
function normaliseUrl(absoluteUrl) {
|
|
14
|
+
if (absoluteUrl === void 0) { absoluteUrl = ""; }
|
|
15
|
+
return (0, removeTrailingSlash_1.default)(absoluteUrl.replace(/([^:]\/)\/+/g, "$1"));
|
|
16
|
+
}
|
|
17
|
+
exports.normaliseUrl = normaliseUrl;
|
|
18
|
+
exports.default = normaliseUrl;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normaliseUrlPathname = void 0;
|
|
4
|
+
var removeTrailingSlash_1 = require("./removeTrailingSlash");
|
|
5
|
+
/**
|
|
6
|
+
* Normalise URL pathname (relative URL)
|
|
7
|
+
*
|
|
8
|
+
* - replaces too many consecutive slashes
|
|
9
|
+
* - removes the trailing slash
|
|
10
|
+
*
|
|
11
|
+
* @category location
|
|
12
|
+
*/
|
|
13
|
+
function normaliseUrlPathname(pathname) {
|
|
14
|
+
if (pathname === void 0) { pathname = ""; }
|
|
15
|
+
return (0, removeTrailingSlash_1.default)(pathname.replace(/\/+/g, "/"));
|
|
16
|
+
}
|
|
17
|
+
exports.normaliseUrlPathname = normaliseUrlPathname;
|
|
18
|
+
exports.default = normaliseUrlPathname;
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// import { isUndefined } from "./is";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.pageview = void 0;
|
|
4
|
+
var isUndefined_1 = require("./isUndefined");
|
|
5
|
+
/**
|
|
6
|
+
* @category analytics-google
|
|
7
|
+
*/
|
|
5
8
|
var pageview = function () {
|
|
6
9
|
var args = [];
|
|
7
10
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8
11
|
args[_i] = arguments[_i];
|
|
9
12
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// }
|
|
13
|
+
if (!(0, isUndefined_1.default)(window) && !(0, isUndefined_1.default)(window.gtag)) {
|
|
14
|
+
window.gtag("event", "page_view", {
|
|
15
|
+
page_path: args[0] || location.pathname,
|
|
16
|
+
page_title: args[1] || document.title,
|
|
17
|
+
page_location: args[2] || location.href,
|
|
18
|
+
// send_to: '<GA_MEASUREMENT_ID>'
|
|
19
|
+
});
|
|
20
|
+
}
|
|
19
21
|
};
|
|
20
22
|
exports.pageview = pageview;
|
|
21
23
|
// export type GtmEventArgs = [
|