Skip to content

Commit

Permalink
[css] enable tests (fixes #74937)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Jun 6, 2019
1 parent b77b0de commit 3ce5cb0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
14 changes: 7 additions & 7 deletions extensions/css-language-features/server/src/test/links.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down

0 comments on commit 3ce5cb0

Please sign in to comment.