23 lines
616 B
JavaScript
23 lines
616 B
JavaScript
"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
|
|
};
|
|
} |