Skip to content

Commit ee534a8

Browse files
authored
Merge pull request #252 from htmlhint/58-replace-uritofilepath-with-vscode-uri
chore: Use vscode-uri
2 parents 6d02d90 + 9c28dba commit ee534a8

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

htmlhint-server/package-lock.json

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

htmlhint-server/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"htmlhint": "^1.5.1",
1212
"strip-json-comments": "3.1.1",
1313
"vscode-languageserver": "9.0.1",
14-
"vscode-languageserver-textdocument": "^1.0.12"
14+
"vscode-languageserver-textdocument": "^1.0.12",
15+
"vscode-uri": "^3.1.0"
1516
},
1617
"devDependencies": {
1718
"@types/node": "22.15.31",

htmlhint-server/src/server.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141
import { TextDocument } from "vscode-languageserver-textdocument";
4242
import * as htmlhint from "htmlhint";
4343
import fs = require("fs");
44+
import { URI } from "vscode-uri";
4445
let stripJsonComments: any = require("strip-json-comments");
4546

4647
interface Settings {
@@ -1481,13 +1482,8 @@ function doValidate(connection: Connection, document: TextDocument): void {
14811482
}
14821483

14831484
let uri = document.uri;
1484-
// Convert URI to file path manually since Files API is not available
1485-
let fsPath = uri.replace(/^file:\/\//, "");
1486-
// Decode URL encoding (e.g., %3A -> :)
1487-
fsPath = decodeURIComponent(fsPath);
1488-
if (process.platform === "win32" && fsPath.startsWith("/")) {
1489-
fsPath = fsPath.substring(1);
1490-
}
1485+
// Convert URI to file path using vscode-uri
1486+
let fsPath = URI.parse(uri).fsPath;
14911487

14921488
trace(`[DEBUG] doValidate called for: ${fsPath}`);
14931489

@@ -1578,14 +1574,9 @@ connection.onDidChangeWatchedFiles((params) => {
15781574
let shouldRevalidate = false;
15791575

15801576
for (let i = 0; i < params.changes.length; i++) {
1581-
// Convert URI to file path manually since Files API is not available
1577+
// Convert URI to file path using vscode-uri
15821578
let uri = params.changes[i].uri;
1583-
let fsPath = uri.replace(/^file:\/\//, "");
1584-
// Decode URL encoding (e.g., %3A -> :)
1585-
fsPath = decodeURIComponent(fsPath);
1586-
if (process.platform === "win32" && fsPath.startsWith("/")) {
1587-
fsPath = fsPath.substring(1);
1588-
}
1579+
let fsPath = URI.parse(uri).fsPath;
15891580

15901581
trace(`[DEBUG] Processing config file change: ${fsPath}`);
15911582
trace(`[DEBUG] Change type: ${params.changes[i].type}`);

htmlhint/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,19 @@
7676
"vscode:prepublish": "npm run compile && npm run bundle-dependencies",
7777
"compile": "tsc -p ./",
7878
"watch": "tsc -watch -p ./",
79-
"bundle-dependencies": "npm install --no-package-lock --no-save htmlhint@^1.5.1 strip-json-comments@3.1.1 vscode-languageserver@9.0.1 vscode-languageserver-textdocument@^1.0.12",
79+
"bundle-dependencies": "npm install --no-package-lock --no-save htmlhint@^1.5.1 strip-json-comments@3.1.1 vscode-languageserver@9.0.1 vscode-languageserver-textdocument@^1.0.12 vscode-uri@^3.1.0",
8080
"package": "vsce package"
8181
},
8282
"devDependencies": {
83-
"typescript": "^5.2.2",
8483
"@types/node": "^22.15.31",
8584
"@types/vscode": "^1.89.0",
85+
"typescript": "^5.2.2",
8686
"vscode-test": "^1.6.1"
8787
},
8888
"dependencies": {
89-
"vscode-languageclient": "9.0.1",
9089
"htmlhint": "^1.5.1",
9190
"strip-json-comments": "3.1.1",
91+
"vscode-languageclient": "9.0.1",
9292
"vscode-languageserver": "9.0.1"
9393
},
9494
"bundleDependencies": [

0 commit comments

Comments
 (0)