Initial commit
This commit is contained in:
commit
b3a51a4115
10336 changed files with 2381973 additions and 0 deletions
35
node_modules/hono/dist/utils/filepath.js
generated
vendored
Normal file
35
node_modules/hono/dist/utils/filepath.js
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// src/utils/filepath.ts
|
||||
var 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);
|
||||
}
|
||||
const path = getFilePathWithoutDefaultDocument({
|
||||
root: options.root,
|
||||
filename
|
||||
});
|
||||
return path;
|
||||
};
|
||||
var getFilePathWithoutDefaultDocument = (options) => {
|
||||
let root = options.root || "";
|
||||
let filename = options.filename;
|
||||
if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) {
|
||||
return;
|
||||
}
|
||||
filename = filename.replace(/^\.?[\/\\]/, "");
|
||||
filename = filename.replace(/\\/, "/");
|
||||
root = root.replace(/\/$/, "");
|
||||
let path = root ? root + "/" + filename : filename;
|
||||
path = path.replace(/^\.?\//, "");
|
||||
if (root[0] !== "/" && path[0] === "/") {
|
||||
return;
|
||||
}
|
||||
return path;
|
||||
};
|
||||
export {
|
||||
getFilePath,
|
||||
getFilePathWithoutDefaultDocument
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue