Files
SnowLuma/.pnpm-store/v11/files/18/227e8f10c92675ecc18298468c16c9af02a512469f63d65c20a5d19b9fa969090a327e43c2f5fc4e56204ea3d9821b250dc69a46026ef2ca8026c56201ef5b
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

28 lines
1.1 KiB
Plaintext

Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
//#region src/utils/filepath.ts
const getFilePath = (options) => {
let filename = options.filename;
const defaultDocument = options.defaultDocument || "index.html";
if (filename.endsWith("/")) filename = filename.concat(defaultDocument);
else if (!filename.match(/\.[a-zA-Z0-9_-]+$/)) filename = filename.concat("/" + defaultDocument);
return getFilePathWithoutDefaultDocument({
root: options.root,
filename
});
};
const getFilePathWithoutDefaultDocument = (options) => {
let root = options.root || "";
let filename = options.filename;
if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) return;
filename = filename.replace(/^\.?[\/\\]/, "");
filename = filename.replace(/\\/g, "/");
root = root.replace(/\/$/, "");
let path = root ? root + "/" + filename : filename;
path = path.replace(/^\.?\//, "");
if (root[0] !== "/" && path[0] === "/") return;
return path;
};
//#endregion
exports.getFilePath = getFilePath;
exports.getFilePathWithoutDefaultDocument = getFilePathWithoutDefaultDocument;