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.html and, 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:// and https:// 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:// and https:// URL inputs in WebviewComm.constructAddress
- ensure
Connection.getFileRelativeToWorkspace returns a leading slash for workspace-relative paths
Bug
Live Preview can generate malformed preview URLs in two related cases:
http://127.0.0.1:3000/http://example.test/page.htmland, depending on the caller-provided value,http://http://....http://127.0.0.1:3000index.html.Expected behavior
http://andhttps://URLs should be preserved as absolute URLs./after the port.Actual behavior
Environment
Proposed fix
I have a small fix and regression tests ready in branch
dknn:codex/fix-live-preview-url-normalization:http://andhttps://URL inputs inWebviewComm.constructAddressConnection.getFileRelativeToWorkspacereturns a leading slash for workspace-relative paths