Repository navigation
fix: handle localhost and port in asWebviewUri - #130148
Joe Previte (jsjoeio) wants to merge 2 commits into
Conversation
|
Not sure how to fix these 😅 |
|
|
||
| let authority = `${resource.scheme}+${resource.authority}.${webviewRootResourceAuthority}`; | ||
| if (resource.authority.includes('localhost')) { | ||
| const authorityUrl = new URL(`http://${resource.authority}`); |
There was a problem hiding this comment.
To fix the layer errors, try using our URI class instead of the built-in URL class
There was a problem hiding this comment.
I think I tried that before but the URI class doesn't have a port (though it does have it in the authority but then I'd have to split it on the :, right?) Unless I leave the port out entirely?
There was a problem hiding this comment.
Matt Bierner (@mjbvz) The URI puts the authority section before the vscode-resource.vscode-webview.net. So the url becomes localhost:8080.vscode-resource.vscode-webview.net which is an invalid port.
Ideally, the URI package could parse the port like URL.
|
Matt Bierner (@mjbvz) is this patch/fix no longer needed thanks to 649dd18? |
|
Possibly? Although I didn't test ports specifically with that fix Did you have a chance to test the issue from #130151? |
|
I spoke to Asher (@code-asher) who tested it and I believe it could fix it: I will have to double-check and follow-up. If it does, I could instead add new tests for URLs with ports |
|
Closing in favor of #131447 |
This PR fixes #130151
We encountered this error in code-server (fix here: coder/code-server#3895) and noticed that resources weren't loading in webviews due to the wrong URI being returned from
asWebviewUri.I don't think Codespaces has the issue because it's always running on a standard port and so it won't have a port in the url.
Additional Context
We noticed this happening with a custom VS Code extension having issues loading resources (CSS & JS) in webviews.
I was going to try and reproduce with
vscodeby runningyarn webbut I'm not seeing the option to manually install VSIX files 🤔