| 10 | |
| 11 | // Test how paths are normalized |
| 12 | function testPathNormalization() { |
| 13 | // Use platform-agnostic path construction instead of hardcoded paths |
| 14 | const testPath = path.join('test', 'project', 'src', 'file.md'); |
| 15 | const absoluteTestPath = path.resolve('test', 'project', 'src', 'file.md'); |
| 16 | |
| 17 | console.log('Testing path normalization:'); |
| 18 | console.log('Relative path:', testPath); |
| 19 | console.log('Absolute path:', absoluteTestPath); |
| 20 | |
| 21 | // Test path.join with different segments |
| 22 | const joinedPath = path.join('test', 'project', 'src', 'file.md'); |
| 23 | console.log('Joined path:', joinedPath); |
| 24 | |
| 25 | // Test path.normalize |
| 26 | console.log('Normalized relative path:', path.normalize(testPath)); |
| 27 | console.log('Normalized absolute path:', path.normalize(absoluteTestPath)); |
| 28 | |
| 29 | // Test how the test would see these paths |
| 30 | const testContent = `--- File: ${absoluteTestPath} ---\nContent\n--- End of File: ${absoluteTestPath} ---`; |
| 31 | console.log('\nTest content with platform-agnostic paths:'); |
| 32 | console.log(testContent); |
| 33 | |
| 34 | // Try to match with different patterns |
| 35 | const marker = `--- File: ${absoluteTestPath} ---`; |
| 36 | console.log('\nTrying to match:', marker); |
| 37 | console.log('Direct match:', testContent.includes(marker)); |
| 38 | |
| 39 | // Test with normalized path in marker |
| 40 | const normalizedMarker = `--- File: ${path.normalize(absoluteTestPath)} ---`; |
| 41 | console.log( |
| 42 | 'Normalized marker match:', |
| 43 | testContent.includes(normalizedMarker), |
| 44 | ); |
| 45 | |
| 46 | // Test path resolution |
| 47 | const __filename = fileURLToPath(import.meta.url); |
| 48 | console.log('\nCurrent file path:', __filename); |
| 49 | console.log('Directory name:', path.dirname(__filename)); |
| 50 | } |
| 51 | |
| 52 | testPathNormalization(); |