Browse Source

Fix #172

run-to-here
Nicolas Petton 3 years ago
parent
commit
46ce30b76d
No known key found for this signature in database GPG Key ID: E8BCD7866AFCF978
2 changed files with 20 additions and 1 deletions
  1. +9
    -1
      server/helpers/workspace.js
  2. +11
    -0
      server/spec/helpers/workspace-spec.js

+ 9
- 1
server/helpers/workspace.js View File

@ -74,10 +74,18 @@ const resolveUrl = (url, conf) => {
// always exist either, so also check for a protocol when parsed
// as a URL.
if (isAbsolute(url) || !parse(url).protocol) {
console.log(`Resolved to ${url}`);
return url;
}
let root = resolveRoot(conf);
let { pathname } = new URL(url);
let { protocol, pathname } = new URL(url);
// Always treat URLs using the file: protocol to have absolute pathnames.
if (protocol === "file:") {
return pathname;
}
return resolve(`${root}/${pathname}`);
};


+ 11
- 0
server/spec/helpers/workspace-spec.js View File

@ -199,6 +199,17 @@ describe("URL resolution", () => {
expect(resolveUrl(url, conf)).toEqual(url);
});
it("resolves file protocol uris", () => {
let conf = {
projectFile: "/home/user/projects/foo/.indium.json"
};
let url = "file:///home/user/projects/foo/bar.js";
expect(resolveUrl(url, conf)).toEqual("/home/user/projects/foo/bar.js");
});
// Regression test for GH issue #161
it("does not transform the path when the file exists on Windows", () => {
let conf = {


Loading…
Cancel
Save