diff --git a/src/languageservice/utils/paths.ts b/src/languageservice/utils/paths.ts index ec364827..b4c2d76a 100644 --- a/src/languageservice/utils/paths.ts +++ b/src/languageservice/utils/paths.ts @@ -3,7 +3,7 @@ import { join, normalize } from 'path'; import { URI } from 'vscode-uri'; export const isRelativePath = (path: string): boolean => { - const relativePathRegex = /^(((\.\.?)|([\w-\. ]+))(\/|\\\\?))*[\w-\. ]*\.[\w-]+$/i; + const relativePathRegex = /^(((\.\.?)|([\w-@\. ]+))(\/|\\\\?))*[\w-\. ]*\.[\w-]+$/i; return relativePathRegex.test(path); }; diff --git a/test/paths.test.ts b/test/paths.test.ts index e15abdab..ca48093a 100644 --- a/test/paths.test.ts +++ b/test/paths.test.ts @@ -132,6 +132,11 @@ suite('File path tests', () => { 'file:///usr/testuser/relative/path/file.json', 'file:///c%3A/Users/testuser/relative/path/file.json'); + checkGoodPath(join('..', '..', 'relative', '@path', 'file.json'), + 'file:///relative/%40path/file.json', + 'file:///usr/testuser/relative/%40path/file.json', + 'file:///c%3A/Users/testuser/relative/%40path/file.json'); + describe('Relative path = a workspace folder', () => { const path1 = join('aFolder', 'file.json'); const path2 = join('folder-2', 'file.json');