-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Revert "♻️ refactor(webview): move webview HTML generation to WebviewHTMLManager" #2502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert "♻️ refactor(webview): move webview HTML generation to WebviewHTMLManager" #2502
Conversation
…HTMLMana…" This reverts commit e70954f.
|
| // Try to read the port from the file | ||
| let localPort = "5173" // Default fallback | ||
| try { | ||
| const fs = require("fs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid mixing import statements with inline require. You already import fs/promises at the top; consider using the imported module to maintain consistency.
| // Try to read the port from the file | ||
| let localPort = "5173" // Default fallback | ||
| try { | ||
| const fs = require("fs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider replacing the synchronous fs operations (fs.existsSync and fs.readFileSync) with the asynchronous ones from 'fs/promises'. Note that 'fs/promises' is already imported at the top, so using the synchronous API here may block the event loop.
| const portFilePath = path.resolve(__dirname, "../.vite-port") | ||
|
|
||
| if (fs.existsSync(portFilePath)) { | ||
| localPort = fs.readFileSync(portFilePath, "utf8").trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate and sanitize the value read from the .vite-port file before using it in URL and CSP string constructions to avoid potential injection issues.
| localPort = fs.readFileSync(portFilePath, "utf8").trim() | |
| localPort = /^[0-9]+$/.test(fs.readFileSync(portFilePath, "utf8").trim()) ? fs.readFileSync(portFilePath, "utf8").trim() : "5173" |
Reverts #2494
#2494 (comment)
Important
Reverts HTML generation refactor by removing
WebviewHTMLManagerand restoring HTML methods inClineProvider.WebviewHTMLManagerby removingWebviewHTMLManager.ts.getHMRHtmlContent()andgetHtmlContent()directly inClineProvider.WebviewHTMLManagerfromClineProvider.ts.getNonceandgetUriinClineProvider.ts.webviewHTMLManagerproperty fromClineProvider.resolveWebviewView()to use restored HTML methods inClineProvider.This description was created by
for d93d7a7. It will automatically update as commits are pushed.