Commit fc84486c authored by tom's avatar tom

fix navigation between files in the same directory

parent 969ca17e
...@@ -9,6 +9,15 @@ it('construct correct absolute path', () => { ...@@ -9,6 +9,15 @@ it('construct correct absolute path', () => {
expect(result).toBe('/foo/abc/contract.sol'); expect(result).toBe('/foo/abc/contract.sol');
}); });
it('construct correct absolute path if file is in the current directory', () => {
const result = getFullPathOfImportedFile(
'/abc/index.sol',
'./contract.sol',
);
expect(result).toBe('/abc/contract.sol');
});
it('returns undefined if imported file is outside the base file folder', () => { it('returns undefined if imported file is outside the base file folder', () => {
const result = getFullPathOfImportedFile( const result = getFullPathOfImportedFile(
'/index.sol', '/index.sol',
......
...@@ -19,7 +19,7 @@ export default function getFullPathOfImportedFile(baseFilePath: string, imported ...@@ -19,7 +19,7 @@ export default function getFullPathOfImportedFile(baseFilePath: string, imported
const result: Array<string> = baseFileChunks.slice(0, -1); const result: Array<string> = baseFileChunks.slice(0, -1);
for (let index = 0; index < importedFileChunks.length - 1; index++) { for (let index = 0; index < importedFileChunks.length; index++) {
const element = importedFileChunks[index]; const element = importedFileChunks[index];
if (element === '.') { if (element === '.') {
...@@ -41,7 +41,5 @@ export default function getFullPathOfImportedFile(baseFilePath: string, imported ...@@ -41,7 +41,5 @@ export default function getFullPathOfImportedFile(baseFilePath: string, imported
return; return;
} }
result.push(importedFileChunks[importedFileChunks.length - 1]);
return '/' + result.join('/'); return '/' + result.join('/');
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment