Skip to content

Commit 5d1d146

Browse files
committed
refactor: DRYs text file extension handling
Removes the dedicated text file extensions constant and instead relies on the `TextExtension` enum defined within supported file types. This change improves maintainability and consolidates file type definitions.
1 parent 94a06de commit 5d1d146

File tree

2 files changed

+3
-38
lines changed

2 files changed

+3
-38
lines changed

tools/server/webui/src/lib/constants/text-file-extensions.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

tools/server/webui/src/lib/utils/text-files.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
* Handles text file detection, reading, and validation
44
*/
55

6-
import { TEXT_FILE_EXTENSIONS } from "$lib/constants/text-file-extensions";
6+
import { TextExtension } from "$lib/constants/supported-file-types";
77

88
/**
99
* Check if a filename indicates a text file based on its extension
1010
* @param filename - The filename to check
1111
* @returns True if the filename has a recognized text file extension
1212
*/
1313
export function isTextFileByName(filename: string): boolean {
14-
return TEXT_FILE_EXTENSIONS.some((ext) => filename.toLowerCase().endsWith(ext));
14+
const textExtensions = Object.values(TextExtension);
15+
return textExtensions.some((ext) => filename.toLowerCase().endsWith(ext));
1516
}
1617

1718
/**

0 commit comments

Comments
 (0)