@koine/utils 1.0.27 → 1.0.30
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/node/normaliseUrl.js +3 -2
- package/node/pageview.js +0 -1
- package/normaliseUrl.d.ts +2 -1
- package/normaliseUrl.js +3 -2
- package/package.json +1 -1
- package/pageview.js +0 -1
package/node/normaliseUrl.js
CHANGED
|
@@ -3,16 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.normaliseUrl = void 0;
|
|
4
4
|
var removeTrailingSlash_1 = require("./removeTrailingSlash");
|
|
5
5
|
/**
|
|
6
|
-
* Normalise URL
|
|
6
|
+
* Normalise URL, it works both for absolute and relative URLs
|
|
7
7
|
*
|
|
8
8
|
* - replaces too many consecutive slashes (except `http{s}://`)
|
|
9
9
|
* - removes the trailing slash
|
|
10
10
|
*
|
|
11
11
|
* @category location
|
|
12
|
+
* @see https://stackoverflow.com/a/40649435/1938970
|
|
12
13
|
*/
|
|
13
14
|
function normaliseUrl(absoluteUrl) {
|
|
14
15
|
if (absoluteUrl === void 0) { absoluteUrl = ""; }
|
|
15
|
-
return (0, removeTrailingSlash_1.default)(absoluteUrl.replace(/(
|
|
16
|
+
return (0, removeTrailingSlash_1.default)(absoluteUrl.replace(/(:\/\/)|(\/)+/g, "$1$2"));
|
|
16
17
|
}
|
|
17
18
|
exports.normaliseUrl = normaliseUrl;
|
|
18
19
|
exports.default = normaliseUrl;
|
package/node/pageview.js
CHANGED
|
@@ -10,7 +10,6 @@ var pageview = function () {
|
|
|
10
10
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
11
|
args[_i] = arguments[_i];
|
|
12
12
|
}
|
|
13
|
-
// FIXME: ambient types
|
|
14
13
|
if (!(0, isUndefined_1.default)(window) && !(0, isUndefined_1.default)(window.gtag)) {
|
|
15
14
|
window.gtag("event", "page_view", {
|
|
16
15
|
page_path: args[0] || location.pathname,
|
package/normaliseUrl.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Normalise URL
|
|
2
|
+
* Normalise URL, it works both for absolute and relative URLs
|
|
3
3
|
*
|
|
4
4
|
* - replaces too many consecutive slashes (except `http{s}://`)
|
|
5
5
|
* - removes the trailing slash
|
|
6
6
|
*
|
|
7
7
|
* @category location
|
|
8
|
+
* @see https://stackoverflow.com/a/40649435/1938970
|
|
8
9
|
*/
|
|
9
10
|
export declare function normaliseUrl(absoluteUrl?: string): string;
|
|
10
11
|
export default normaliseUrl;
|
package/normaliseUrl.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import removeTralingSlash from "./removeTrailingSlash";
|
|
2
2
|
/**
|
|
3
|
-
* Normalise URL
|
|
3
|
+
* Normalise URL, it works both for absolute and relative URLs
|
|
4
4
|
*
|
|
5
5
|
* - replaces too many consecutive slashes (except `http{s}://`)
|
|
6
6
|
* - removes the trailing slash
|
|
7
7
|
*
|
|
8
8
|
* @category location
|
|
9
|
+
* @see https://stackoverflow.com/a/40649435/1938970
|
|
9
10
|
*/
|
|
10
11
|
export function normaliseUrl(absoluteUrl) {
|
|
11
12
|
if (absoluteUrl === void 0) { absoluteUrl = ""; }
|
|
12
|
-
return removeTralingSlash(absoluteUrl.replace(/(
|
|
13
|
+
return removeTralingSlash(absoluteUrl.replace(/(:\/\/)|(\/)+/g, "$1$2"));
|
|
13
14
|
}
|
|
14
15
|
export default normaliseUrl;
|
package/package.json
CHANGED
package/pageview.js
CHANGED
|
@@ -7,7 +7,6 @@ export var pageview = function () {
|
|
|
7
7
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8
8
|
args[_i] = arguments[_i];
|
|
9
9
|
}
|
|
10
|
-
// FIXME: ambient types
|
|
11
10
|
if (!isUndefined(window) && !isUndefined(window.gtag)) {
|
|
12
11
|
window.gtag("event", "page_view", {
|
|
13
12
|
page_path: args[0] || location.pathname,
|