Buckets:
| // 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 | |
| }; | |
Xet Storage Details
- Size:
- 1.02 kB
- Xet hash:
- 09e84a8f972f671d4802291385a6b0faf00973c133becc9c5083b2f4d725ca30
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.