diff --git a/gitnexus/src/core/ingestion/framework-detection.ts b/gitnexus/src/core/ingestion/framework-detection.ts index 9ea43800c..c20015205 100644 --- a/gitnexus/src/core/ingestion/framework-detection.ts +++ b/gitnexus/src/core/ingestion/framework-detection.ts @@ -34,10 +34,12 @@ export interface FrameworkHint { */ export function detectFrameworkFromPath(filePath: string): FrameworkHint | null { // Normalize path separators and ensure leading slash for consistent matching - let p = filePath.toLowerCase().replace(/\\/g, '/'); + const originalPath = filePath.replace(/\\/g, '/'); + let p = originalPath.toLowerCase(); if (!p.startsWith('/')) { p = '/' + p; // Add leading slash so patterns like '/app/' match 'app/...' } + const originalPathWithLeadingSlash = originalPath.startsWith('/') ? originalPath : `/${originalPath}`; // ========== JAVASCRIPT / TYPESCRIPT FRAMEWORKS ========== @@ -128,7 +130,7 @@ export function detectFrameworkFromPath(filePath: string): FrameworkHint | null (p.endsWith('.tsx') || p.endsWith('.jsx')) ) { // Only boost if PascalCase filename (likely a component, not util) - const fileName = p.split('/').pop() || ''; + const fileName = originalPathWithLeadingSlash.split('/').pop() || ''; if (/^[A-Z]/.test(fileName)) { return { framework: 'react', entryPointMultiplier: 1.5, reason: 'react-component' }; } diff --git a/gitnexus/test/unit/framework-detection.test.ts b/gitnexus/test/unit/framework-detection.test.ts index b07580044..ce9d76f10 100644 --- a/gitnexus/test/unit/framework-detection.test.ts +++ b/gitnexus/test/unit/framework-detection.test.ts @@ -90,12 +90,11 @@ describe('detectFrameworkFromPath', () => { describe('React', () => { it('has React component detection rule for views/components folders', () => { - // Note: The current implementation lowercases the path before checking - // PascalCase, so PascalCase detection currently can't match. - // This test documents the current behavior. const result = detectFrameworkFromPath('views/Button.tsx'); - // Returns null because path is lowercased before PascalCase regex check - expect(result).toBeNull(); + expect(result).not.toBeNull(); + expect(result!.framework).toBe('react'); + expect(result!.entryPointMultiplier).toBe(1.5); + expect(result!.reason).toBe('react-component'); }); });