29 lines
1.2 KiB
JavaScript
Executable File
29 lines
1.2 KiB
JavaScript
Executable File
"use strict";
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
Object.defineProperty(exports, "assignLocation", {
|
|
enumerable: true,
|
|
get: function() {
|
|
return assignLocation;
|
|
}
|
|
});
|
|
const _addbasepath = require("./add-base-path");
|
|
function assignLocation(location, url) {
|
|
if (location.startsWith('.')) {
|
|
const urlBase = url.origin + url.pathname;
|
|
return new URL(// In order for a relative path to be added to the current url correctly, the current url must end with a slash
|
|
// new URL('./relative', 'https://example.com/subdir').href -> 'https://example.com/relative'
|
|
// new URL('./relative', 'https://example.com/subdir/').href -> 'https://example.com/subdir/relative'
|
|
(urlBase.endsWith('/') ? urlBase : urlBase + '/') + location);
|
|
}
|
|
return new URL((0, _addbasepath.addBasePath)(location), url.href);
|
|
}
|
|
|
|
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
Object.assign(exports.default, exports);
|
|
module.exports = exports.default;
|
|
}
|
|
|
|
//# sourceMappingURL=assign-location.js.map
|