microsoft / microsoft/vscode-livepreview
Live Preview can generate malformed URLs for absolute links and workspace paths
Open
Beginner friendly
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 596
- Forks
- 119
- Avg merge
- 1d 4m
- Merged PRs (30d)
- 5
Description
Bug
Live Preview can generate malformed preview URLs in two related cases:
- Absolute HTTP(S) URLs can be prefixed with the preview host, producing URLs such as
http://127.0.0.1:3000/http://example.test/page.htmland, depending on the caller-provided value,http://http://.... - Workspace-relative paths can be returned without a leading slash when the workspace root already ends with a path separator, producing a URL with the path joined directly after the port, e.g.
http://127.0.0.1:3000index.html.
Expected behavior
- Absolute
http://andhttps://URLs should be preserved as absolute URLs. - Preview paths served from the local Live Preview host should include
/after the port.
Actual behavior
- Absolute HTTP(S) URLs can be treated as local preview paths and receive another host/protocol prefix.
- In trailing-separator workspace cases, the path can be appended immediately after the port.
Environment
- Extension: Live Preview 0.4.18 local build, also observed while testing 0.4.19 install behavior
- OS: Windows
- Workspace type involved in repro: local/network workspace path where the resolved workspace root can include a trailing separator
Proposed fix
I have a small fix and regression tests ready in branch dknn:codex/fix-live-preview-url-normalization:
- preserve absolute
http://andhttps://URL inputs inWebviewComm.constructAddress - ensure
Connection.getFileRelativeToWorkspacereturns a leading slash for workspace-relative paths
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting WebviewComm.constructAddress and Connection.getFileRelativeToWorkspace, focusing on absolute HTTP(S) inputs and workspace roots with trailing separators. Reproduce both malformed URL cases, then run or extend the regression tests mentioned in the issue. Done means absolute URLs remain unchanged and local preview paths always have a slash after the port.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 64/100