Atom eve seo
This commit is contained in:
67
.output/server/_libs/ufo.mjs
Normal file
67
.output/server/_libs/ufo.mjs
Normal file
@@ -0,0 +1,67 @@
|
||||
import { fileURLToPath as __eveFileURLToPath } from "node:url";
|
||||
import { dirname as __eveDirname } from "node:path";
|
||||
__eveDirname(__eveFileURLToPath(import.meta.url));
|
||||
String.fromCharCode;
|
||||
const ENC_SLASH_RE = /%2f/gi;
|
||||
function decode(text = "") {
|
||||
try {
|
||||
return decodeURIComponent("" + text);
|
||||
} catch {
|
||||
return "" + text;
|
||||
}
|
||||
}
|
||||
function decodePath(text) {
|
||||
return decode(text.replace(ENC_SLASH_RE, "%252F"));
|
||||
}
|
||||
const TRAILING_SLASH_RE = /\/$|\/\?|\/#/;
|
||||
const JOIN_LEADING_SLASH_RE = /^\.?\//;
|
||||
function hasTrailingSlash(input = "", respectQueryAndFragment) {
|
||||
if (!respectQueryAndFragment) return input.endsWith("/");
|
||||
return TRAILING_SLASH_RE.test(input);
|
||||
}
|
||||
function withoutTrailingSlash(input = "", respectQueryAndFragment) {
|
||||
if (!respectQueryAndFragment) return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
|
||||
if (!hasTrailingSlash(input, true)) return input || "/";
|
||||
let path = input;
|
||||
let fragment = "";
|
||||
const fragmentIndex = input.indexOf("#");
|
||||
if (fragmentIndex !== -1) {
|
||||
path = input.slice(0, fragmentIndex);
|
||||
fragment = input.slice(fragmentIndex);
|
||||
}
|
||||
const [s0, ...s] = path.split("?");
|
||||
return ((s0.endsWith("/") ? s0.slice(0, -1) : s0) || "/") + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
||||
}
|
||||
function withTrailingSlash(input = "", respectQueryAndFragment) {
|
||||
if (!respectQueryAndFragment) return input.endsWith("/") ? input : input + "/";
|
||||
if (hasTrailingSlash(input, true)) return input || "/";
|
||||
let path = input;
|
||||
let fragment = "";
|
||||
const fragmentIndex = input.indexOf("#");
|
||||
if (fragmentIndex !== -1) {
|
||||
path = input.slice(0, fragmentIndex);
|
||||
fragment = input.slice(fragmentIndex);
|
||||
if (!path) return fragment;
|
||||
}
|
||||
const [s0, ...s] = path.split("?");
|
||||
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
||||
}
|
||||
function hasLeadingSlash(input = "") {
|
||||
return input.startsWith("/");
|
||||
}
|
||||
function withLeadingSlash(input = "") {
|
||||
return hasLeadingSlash(input) ? input : "/" + input;
|
||||
}
|
||||
function isNonEmptyURL(url) {
|
||||
return url && url !== "/";
|
||||
}
|
||||
function joinURL(base, ...input) {
|
||||
let url = base || "";
|
||||
for (const segment of input.filter((url2) => isNonEmptyURL(url2))) if (url) {
|
||||
const _segment = segment.replace(JOIN_LEADING_SLASH_RE, "");
|
||||
url = withTrailingSlash(url) + _segment;
|
||||
} else url = segment;
|
||||
return url;
|
||||
}
|
||||
//#endregion
|
||||
export { withoutTrailingSlash as i, joinURL as n, withLeadingSlash as r, decodePath as t };
|
||||
Reference in New Issue
Block a user