Fix SyntaxError: Unexpected token '&' caused by HTML entity encoding in script#35
Fix SyntaxError: Unexpected token '&' caused by HTML entity encoding in script#35
Conversation
…cript Co-authored-by: mahata <23497+mahata@users.noreply.github.com>
Co-authored-by: mahata <23497+mahata@users.noreply.github.com>
|
@copilot I like the general idea of this PR! However, I'd prefer if |
Co-authored-by: mahata <23497+mahata@users.noreply.github.com>
I've converted The changes include:
The TypeScript compiler now watches for changes and automatically recompiles the client-side code. Changes to |
|
@copilot Fix CI in GitHub Actions. |
Co-authored-by: mahata <23497+mahata@users.noreply.github.com>
Fixed CI issues by resolving linting problems. The CI was failing because:
Updated the CI workflow to clean build artifacts before linting and fixed all source code linting issues. CI now passes all steps: tests, linting, and build. (0fd103a) |
Problem
The MLack chat application was showing a JavaScript syntax error when accessing the root page (
/):This error occurred because single quotes in inline JavaScript were being HTML entity encoded as
'when Hono rendered the JSX to HTML. For example:The
'HTML entities broke JavaScript syntax, preventing the WebSocket functionality from working.Solution
Extracted the inline JavaScript from the JSX template literal to a separate external file to avoid HTML encoding:
/hono/static/ChatPage.js- External JavaScript file with WebSocket functionality/hono/components/ChatPage.tsx- Replaced inline<script>with<script src="/static/ChatPage.js">/hono/app.tsx- Added static file serving for/static/*pathBefore vs After
Before (broken):
After (working):
Where
ChatPage.jscontains:Result
✅ The application now loads without JavaScript syntax errors
✅ WebSocket functionality works correctly
✅ Browser console shows "Connected to WebSocket" instead of syntax errors
✅ All existing tests pass
Fixes #34.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.