32 行
1.1 KiB
JavaScript
32 行
1.1 KiB
JavaScript
|
|
import assert from 'node:assert/strict'
|
||
|
|
import test from 'node:test'
|
||
|
|
|
||
|
|
import { sanitizeSourcePath } from './source-map.mjs'
|
||
|
|
|
||
|
|
test('Unix sources distinguish project files from external absolute paths', () => {
|
||
|
|
assert.equal(sanitizeSourcePath('/workspace/app/src/Home.tsx', '/workspace/app'), 'src/Home.tsx')
|
||
|
|
assert.equal(
|
||
|
|
sanitizeSourcePath('/Users/alice/shared/secret.ts', '/workspace/app'),
|
||
|
|
'external/secret.ts',
|
||
|
|
)
|
||
|
|
assert.equal(
|
||
|
|
sanitizeSourcePath('/Users/alice/app/node_modules/react/index.js', '/workspace/app'),
|
||
|
|
'external/node_modules/react/index.js',
|
||
|
|
)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('Windows sources distinguish project files without leaking host directories', () => {
|
||
|
|
assert.equal(
|
||
|
|
sanitizeSourcePath('C:\\workspace\\app\\src\\Home.tsx', 'C:\\workspace\\app'),
|
||
|
|
'src/Home.tsx',
|
||
|
|
)
|
||
|
|
assert.equal(
|
||
|
|
sanitizeSourcePath('D:\\Users\\alice\\private\\secret.ts', 'C:\\workspace\\app'),
|
||
|
|
'external/secret.ts',
|
||
|
|
)
|
||
|
|
assert.equal(
|
||
|
|
sanitizeSourcePath('D:\\cache\\node_modules\\react\\index.js', 'C:\\workspace\\app'),
|
||
|
|
'external/node_modules/react/index.js',
|
||
|
|
)
|
||
|
|
})
|