Skip to content

Commit 67439f9

Browse files
authored
Merge pull request #126 from UziTech/fix-url
2 parents 60f2929 + a4f2982 commit 67439f9

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib/convert.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type * as atomIde from "atom-ide-base"
22
import * as ls from "./languageclient"
3-
import * as URL from "url"
43
import { Point, FilesystemChange, Range, TextEditor } from "atom"
54

65
/**
@@ -31,12 +30,12 @@ export default class Convert {
3130
* to deal with http/https sources in the future.
3231
*/
3332
public static uriToPath(uri: string): string {
34-
const url = URL.parse(uri) /*eslint node/no-deprecated-api: "warn"*/ // TODO
35-
if (url.protocol !== "file:" || url.path === undefined || url.path === null) {
33+
const url = new URL(uri, "file://")
34+
if (url.protocol !== "file:" || url.pathname == null) {
3635
return uri
3736
}
3837

39-
let filePath = decodeURIComponent(url.path)
38+
let filePath = decodeURIComponent(url.pathname)
4039
if (process.platform === "win32") {
4140
// Deal with Windows drive names
4241
if (filePath[0] === "/") {

test/convert.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe("Convert", () => {
6666

6767
it("decodes Windows drive specifiers", () => {
6868
setProcessPlatform("win32")
69-
expect(Convert.uriToPath("file:///d:/ee/ff.txt")).equals("d:\\ee\\ff.txt")
69+
expect(Convert.uriToPath("file:///d:/ee/ff.txt").toLowerCase()).equals("d:\\ee\\ff.txt")
7070
})
7171

7272
it("URI decodes special characters", () => {
@@ -81,7 +81,7 @@ describe("Convert", () => {
8181

8282
it("parses URI without double slash in the beginning on Windows", () => {
8383
setProcessPlatform("win32")
84-
expect(Convert.uriToPath("file:/x:/a/b/c/d.txt")).equals("x:\\a\\b\\c\\d.txt")
84+
expect(Convert.uriToPath("file:/x:/a/b/c/d.txt").toLowerCase()).equals("x:\\a\\b\\c\\d.txt")
8585
})
8686
})
8787

0 commit comments

Comments
 (0)