fix(webview): rewrite dynamic imports only inside script bodies

The root-absolute import("/...") rewrite ran over the whole document, so
visible text such as <pre>import("/x")</pre> was rewritten too. Run the
specifier rewrite per <script> body and leave markup text untouched.
This commit is contained in:
ArizeSky committed 2026-11-16 16:12:53 +08:00
1 parent cc413afdd1
commit 06100a5506
4 files changed
+63 -18

No files matched your search

+1 -1
View File
@@ -2,4 +2,4 @@
"aicodeman": patch
---
Web tabs whose dashboard ships a relative `<base href>` render again. The proxy rewrites the document URL to strip its `/webview/<cap>/` prefix, and a relative base is resolved against that URL — so `./` (what Vite builds emit, DeepSeek Harness among them) pointed at Codeman's root: every module script 404'd and the page painted its background with nothing on it. The rewrite now resolves such a base against the document's own directory inside the proxy prefix before the mask runs (a page at `/webview/<cap>/app/page.html` gets `/webview/<cap>/app/`, not the proxy root); a cross-origin base is left exactly as the author wrote it.
Web tabs whose dashboard ships a relative `<base href>` render again. The proxy rewrites the document URL to strip its `/webview/<cap>/` prefix, and a relative base is resolved against that URL — so `./` (what Vite builds emit, DeepSeek Harness among them) pointed at Codeman's root: every module script 404'd and the page painted its background with nothing on it. The rewrite now resolves such a base against the document's own directory inside the proxy prefix before the mask runs (a page at `/webview/<cap>/app/page.html` gets `/webview/<cap>/app/`, not the proxy root); a cross-origin base is left exactly as the author wrote it. The root-absolute `import("/...")` rewrite is confined to `<script>` bodies, so a `<pre>import("/x")</pre>` example is no longer rewritten as if it were a loader.