Repository navigation
fix(app): resolve URL-style paths against the workspace on Windows - #58178
harshitsharmaaaa wants to merge 1 commit into
Conversation
On Windows the server resolves a single leading separator relative to its process drive, so a URL-style path like /static/render/x.mp4 was read from C:\static and failed with a 500. Two places sent such paths as absolute: the file model normalized them outside the workspace and readLocalImage scoped them to the drive root parent directory. Detect Windows scopes (drive letter or UNC directory) and treat drive-less, non-UNC paths as workspace-relative in both places. Full drive paths, file:// paths with a drive, and UNC paths (double separators) keep their absolute handling, so POSIX and out-of-project reads are unchanged. Covers regression tests for the file model, image reads, and the markdown image contract.
c816b90 to
3e60820
Compare
There was a problem hiding this comment.
Looks sound. I checked it by calling the path normaliser and readLocalImage directly on the base and on this branch, with a stub file API. On the base, /static/render/x.mp4 in a C:\repo workspace stays absolute, and the image read goes to directory /static/, which is the drive-root read from #50913. With this change, both resolve inside the workspace (static/render/x.mp4, and static/cover.png from C:/project). Drive paths, UNC paths (//server/share, \\server\share), /C:/… file-URL forms and POSIX workspaces behave as before. The unit tests for both files and the packages/app type check pass. I couldn't test against a real Windows server or the desktop app, and I didn't run the changed Playwright spec.
Public API is unchanged; these are client-side helpers in packages/app only.
No blocking concerns.
There was a problem hiding this comment.
The new commits only move the branch onto a newer dev; the change itself is the same as in the version I reviewed. I reran the unit tests for path.ts and image.ts and the packages/app type check on the new head, and both pass. Calling the path code directly still gives the fixed result: a Windows workspace now reads /static/... from inside the project, and drive and UNC paths are unchanged. I couldn't test against a real Windows server or the desktop app.
Public API is unchanged.
No new concerns.
Issue for this PR
Closes #50913
Type of change
What does this PR do?
On Windows, a path such as
/static/render/x.mp4was treated as an absolute path even when it referred to a file inside the project. This caused the application to resolve it against the server's drive root (for example,C:\static) instead of the workspace.This change treats paths with a single leading slash or backslash as workspace-relative when the workspace is on Windows and the path has no drive prefix or UNC prefix. It updates both file-path normalization and local image reads. Drive-qualified paths and UNC paths retain their existing behavior, and POSIX path handling remains unchanged.
How did you verify your code works?
packages/appunit tests: 768 passed across 109 files.bun run check(lint and typecheck): passed.Screenshots / recordings
Not applicable. This is a filesystem path-resolution fix and does not introduce a visual UI change.
Checklist