generated from erangel1/generic-template
initial commit. phase 1 complete
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = parseUrl;
|
||||
function parseUrl(url) {
|
||||
var _url2;
|
||||
const defaultUrl = new URL("http://localhost:3000/api/auth");
|
||||
if (url && !url.startsWith("http")) {
|
||||
url = `https://${url}`;
|
||||
}
|
||||
const _url = new URL((_url2 = url) !== null && _url2 !== void 0 ? _url2 : defaultUrl);
|
||||
const path = (_url.pathname === "/" ? defaultUrl.pathname : _url.pathname).replace(/\/$/, "");
|
||||
const base = `${_url.origin}${path}`;
|
||||
return {
|
||||
origin: _url.origin,
|
||||
host: _url.host,
|
||||
path,
|
||||
base,
|
||||
toString: () => base
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user