diff --git a/frontend/src/lib/parsing.ts b/frontend/src/lib/parsing.ts index 2fd53d3..5aa3c8e 100644 --- a/frontend/src/lib/parsing.ts +++ b/frontend/src/lib/parsing.ts @@ -7,6 +7,26 @@ export const SUPPORTED_EXTENSIONS = [ ".md", ".py", ".json", + ".js", + ".ts", + ".tsx", + ".jsx", + ".go", + ".rs", + ".java", + ".c", + ".cpp", + ".h", + ".hpp", + ".html", + ".css", + ".yaml", + ".yml", + ".toml", + ".xml", + ".sql", + ".sh", + ".bash", ]; export function hasSupportedExtension(name: string): boolean { diff --git a/src/norefund/core/parsing.py b/src/norefund/core/parsing.py index 13e22a4..8e8eba9 100644 --- a/src/norefund/core/parsing.py +++ b/src/norefund/core/parsing.py @@ -7,7 +7,35 @@ logger = logging.getLogger(__name__) -SUPPORTED_EXTENSIONS = {".pdf", ".pptx", ".docx", ".txt", ".md", ".py", ".json"} +SUPPORTED_EXTENSIONS = { + ".pdf", + ".pptx", + ".docx", + ".txt", + ".md", + ".py", + ".json", + ".js", + ".ts", + ".tsx", + ".jsx", + ".go", + ".rs", + ".java", + ".c", + ".cpp", + ".h", + ".hpp", + ".html", + ".css", + ".yaml", + ".yml", + ".toml", + ".xml", + ".sql", + ".sh", + ".bash", +} def extract_text(path: Path) -> str: diff --git a/src/norefund/core/service.py b/src/norefund/core/service.py index 3da6922..97716ab 100644 --- a/src/norefund/core/service.py +++ b/src/norefund/core/service.py @@ -6,6 +6,8 @@ from __future__ import annotations +from .parsing import SUPPORTED_EXTENSIONS, extract_text + import threading from collections.abc import Callable from dataclasses import dataclass @@ -23,8 +25,6 @@ from norefund.logging_config import get_logger _LOG = get_logger(__name__) -_SUPPORTED = {".txt", ".md", ".pdf", ".pptx", ".docx", ".py", ".json"} - @dataclass class AnalysisResult: @@ -137,7 +137,7 @@ def analyze_folder( ) break - if not (f.is_file() and f.suffix.lower() in _SUPPORTED): + if not (f.is_file() and f.suffix.lower() in SUPPORTED_EXTENSIONS): continue # analyze_file already catches all exceptions internally diff --git a/tests/test_desktop_api.py b/tests/test_desktop_api.py index 9597a8d..b45dc40 100644 --- a/tests/test_desktop_api.py +++ b/tests/test_desktop_api.py @@ -148,6 +148,9 @@ def test_pick_files_filters_to_supported_extensions(): (pattern,) = kwargs["file_types"] assert "*.pdf" in pattern assert "*.docx" in pattern + assert "*.java" in pattern + assert "*.js;" in pattern + assert "*.cpp" in pattern def test_pick_files_returns_empty_list_when_dialog_is_cancelled(): diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 78b760b..2810c6f 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -5,11 +5,35 @@ from norefund.core.parsing import SUPPORTED_EXTENSIONS, extract_text -def test_supported_extensions_present(): - assert ".pdf" in SUPPORTED_EXTENSIONS - assert ".pptx" in SUPPORTED_EXTENSIONS - assert ".docx" in SUPPORTED_EXTENSIONS - assert ".txt" in SUPPORTED_EXTENSIONS +def test_supported_code_extensions_present(): + expected = { + ".pdf", + ".pptx", + ".docx", + ".txt", + ".js", + ".ts", + ".tsx", + ".jsx", + ".go", + ".rs", + ".java", + ".c", + ".cpp", + ".h", + ".hpp", + ".html", + ".css", + ".yaml", + ".yml", + ".toml", + ".xml", + ".sql", + ".sh", + ".bash", + } + + assert expected <= SUPPORTED_EXTENSIONS def test_extract_text_txt(tmp_path: Path):