Repository URL to install this package:
Version:
2.0.11-8 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const url = require("url");
function forceConsistentEndingSlash(args) {
if (args.src.endsWith("/")) {
if (args.dest.endsWith("/")) {
return args.dest;
}
else {
return args.dest + "/";
}
}
else {
if (args.dest.endsWith("/")) {
return args.dest.slice(0, args.dest.length - 1);
}
else {
return args.dest;
}
}
}
function getSchemeUrl(args) {
const parsed = url.parse(args.httpUrl, true);
parsed.protocol = args.protocol + ":";
parsed.port = null;
parsed.host = null;
const schemeUrl = url.format(parsed);
return forceConsistentEndingSlash({
src: args.httpUrl,
dest: schemeUrl,
});
}
exports.getSchemeUrl = getSchemeUrl;
function getHttpUrl(args) {
const parsedBaseURL = url.parse(args.baseUrl);
const parsed = url.parse(args.schemeUrl, true);
parsed.protocol = parsedBaseURL.protocol;
parsed.port = parsedBaseURL.port;
parsed.host = parsedBaseURL.host;
const httpUrl = url.format(parsed);
return forceConsistentEndingSlash({
src: args.schemeUrl,
dest: httpUrl,
});
}
exports.getHttpUrl = getHttpUrl;
function fixSchemeUrl(args) {
if (!args.url.startsWith(args.protocol + ":")) {
return args.url;
}
const parsedBaseUrl = url.parse(args.baseUrl, true);
const parsed = url.parse(args.url, true);
if (parsed.hostname === parsedBaseUrl.hostname) {
return args.url;
}
return args.url.replace(`${args.protocol}://*`, `${args.protocol}:/`);
}
exports.fixSchemeUrl = fixSchemeUrl;
//# sourceMappingURL=schemeHelpers.js.map
//notion-enhancer
require('notion-enhancer/pkg/loader.js')(__filename, exports);