remove unneeded normalize-path

This commit is contained in:
Patrick Erichsen
2025-10-17 14:42:24 -07:00
parent c38a5bbd9d
commit a9f7015b8f
3 changed files with 8 additions and 32 deletions

View File

@@ -31,7 +31,6 @@
"@types/mozilla-readability": "^0.2.1",
"@types/mustache": "^4.2.5",
"@types/node-fetch": "^2.6.11",
"@types/normalize-path": "^3.0.2",
"@types/pg": "^8.11.6",
"@types/plist": "^3.0.5",
"@types/request": "^2.48.12",
@@ -102,7 +101,6 @@
"mac-ca": "^3.1.0",
"node-fetch": "^3.3.2",
"node-html-markdown": "^1.3.0",
"normalize-path": "^3.0.0",
"ollama": "^0.4.6",
"onnxruntime-node": "1.14.0",
"openai": "^5.13.1",

View File

@@ -1,25 +0,0 @@
import * as os from "os";
import * as path from "path";
import { normalizeDisplayPath } from "./pathResolver";
describe("normalizeDisplayPath", () => {
it("should contract home directory to ~", () => {
const homedir = os.homedir();
expect(
normalizeDisplayPath(path.join(homedir, "Documents", "file.txt")),
).toBe("~/Documents/file.txt");
expect(normalizeDisplayPath("/usr/local/bin")).toBe("/usr/local/bin");
});
it("should handle root home directory", () => {
const homedir = os.homedir();
expect(normalizeDisplayPath(homedir)).toBe("~");
});
it("should not contract paths that aren't under home", () => {
expect(normalizeDisplayPath("/var/log/messages")).toBe("/var/log/messages");
expect(normalizeDisplayPath("/usr/local/bin")).toBe("/usr/local/bin");
});
});

View File

@@ -1,5 +1,4 @@
import { fileURLToPath, pathToFileURL } from "node:url";
import normalizePath from "normalize-path";
import * as path from "path";
import untildify from "untildify";
import { IDE } from "..";
@@ -15,11 +14,18 @@ export interface ResolvedPath {
/**
* Checks if a URI is within any of the workspace directories
* Also verifies the file actually exists, matching the behavior of resolveRelativePathInDir
*/
async function isUriWithinWorkspace(ide: IDE, uri: string): Promise<boolean> {
const workspaceDirs = await ide.getWorkspaceDirs();
const { foundInDir } = findUriInDirs(uri, workspaceDirs);
return foundInDir !== null;
// Check both: within workspace path AND file exists
if (foundInDir !== null) {
return await ide.fileExists(uri);
}
return false;
}
export async function resolveInputPath(
@@ -52,9 +58,6 @@ export async function resolveInputPath(
/^[a-zA-Z]:/.test(expandedPath);
if (isAbsolute) {
// Normalize for cross-platform compatibility (converts \ to /)
const normalizedPath = normalizePath(expandedPath);
// Convert to file:// URI format
const uri = pathToFileURL(expandedPath).href;
const isWithinWorkspace = await isUriWithinWorkspace(ide, uri);