[css] enable tests (fixes #74937)
This commit is contained in:
parent
b77b0defc4
commit
3ce5cb0e02
2 changed files with 17 additions and 13 deletions
|
@ -67,13 +67,13 @@ suite('Links', () => {
|
|||
);
|
||||
});
|
||||
|
||||
// test('url links', function () {
|
||||
test('node module resolving', function () {
|
||||
|
||||
// let testUri = getTestResource('about.css');
|
||||
// let folders = [{ name: 'x', uri: getTestResource('') }];
|
||||
let testUri = getTestResource('about.css');
|
||||
let folders = [{ name: 'x', uri: getTestResource('') }];
|
||||
|
||||
// assertLinks('html { background-image: url("~foo/hello.html|")',
|
||||
// [{ offset: 29, value: '"~foo/hello.html"', target: getTestResource('node_modules/foo/hello.html') }], testUri, folders
|
||||
// );
|
||||
// });
|
||||
assertLinks('html { background-image: url("~foo/hello.html|")',
|
||||
[{ offset: 29, value: '"~foo/hello.html"', target: getTestResource('node_modules/foo/hello.html') }], testUri, folders
|
||||
);
|
||||
});
|
||||
});
|
|
@ -57,13 +57,17 @@ export function getDocumentContext(documentUri: string, workspaceFolders: Worksp
|
|||
// and [sass-loader's](https://github.com/webpack-contrib/sass-loader#imports)
|
||||
// convention, if an import path starts with ~ then use node module resolution
|
||||
// *unless* it starts with "~/" as this refers to the user's home directory.
|
||||
if (ref[0] === '~' && ref[1] !== '/' && startsWith(base, 'file://')) {
|
||||
const moduleName = getModuleNameFromPath(ref.substring(1));
|
||||
const modulePath = resolvePathToModule(moduleName, base);
|
||||
if (modulePath) {
|
||||
const pathWithinModule = ref.substring(moduleName.length + 2);
|
||||
return url.resolve(modulePath, pathWithinModule);
|
||||
if (ref[0] === '~' && ref[1] !== '/') {
|
||||
ref = ref.substring(1);
|
||||
if (startsWith(base, 'file://')) {
|
||||
const moduleName = getModuleNameFromPath(ref);
|
||||
const modulePath = resolvePathToModule(moduleName, base);
|
||||
if (modulePath) {
|
||||
const pathWithinModule = ref.substring(moduleName.length + 1);
|
||||
return url.resolve(modulePath, pathWithinModule);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return url.resolve(base, ref);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue