Первая версия
This commit is contained in:
20
src/core/TextFilePolicy.js
Normal file
20
src/core/TextFilePolicy.js
Normal file
@@ -0,0 +1,20 @@
|
||||
export class TextFilePolicy {
|
||||
constructor() {
|
||||
this.maxSizeBytes = 5 * 1024 * 1024;
|
||||
this.allowedExtensions = new Set([
|
||||
".txt", ".md", ".json", ".xml", ".yaml", ".yml", ".js", ".jsx", ".ts", ".tsx",
|
||||
".css", ".html", ".py", ".java", ".go", ".rs", ".sql", ".sh", ".env", ".ini", ".toml"
|
||||
]);
|
||||
}
|
||||
|
||||
isTextPath(path) {
|
||||
const idx = path.lastIndexOf(".");
|
||||
if (idx === -1) return true;
|
||||
const ext = path.slice(idx).toLowerCase();
|
||||
return this.allowedExtensions.has(ext);
|
||||
}
|
||||
|
||||
isSupportedFile(path, size) {
|
||||
return this.isTextPath(path) && size <= this.maxSizeBytes;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user