@koine/utils 1.0.28 → 1.0.31
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/isServer.js +4 -3
- package/node/isServer.js +4 -3
- package/node/normaliseUrl.js +3 -2
- package/normaliseUrl.d.ts +2 -1
- package/normaliseUrl.js +3 -2
- package/package.json +1 -1
package/isServer.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import isBrowser from "./isBrowser";
|
|
1
|
+
// import isBrowser from "./isBrowser";
|
|
2
2
|
/**
|
|
3
3
|
* @category ssr
|
|
4
4
|
* @category is
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
7
|
-
|
|
6
|
+
// export const isServer = !isBrowser;
|
|
7
|
+
export var isServer = typeof window === "undefined";
|
|
8
|
+
// export const isServer = () => typeof window === "undefined";
|
|
8
9
|
export default isServer;
|
package/node/isServer.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// import isBrowser from "./isBrowser";
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.isServer = void 0;
|
|
4
|
-
var isBrowser_1 = require("./isBrowser");
|
|
5
5
|
/**
|
|
6
6
|
* @category ssr
|
|
7
7
|
* @category is
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// export const isServer = !isBrowser;
|
|
10
|
+
exports.isServer = typeof window === "undefined";
|
|
11
|
+
// export const isServer = () => typeof window === "undefined";
|
|
11
12
|
exports.default = exports.isServer;
|
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/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;
|