Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function htmlInlineProxyPlugin(config: ResolvedConfig): Plugin {
const index = Number(proxyMatch[1])
const file = cleanUrl(id)
const url = file.replace(normalizePath(config.root), '')
const result = htmlProxyMap.get(config)!.get(url)![index]
const result = htmlProxyMap.get(config)!.get(url)?.[index]
if (result) {
return result
} else {
Expand Down
1 change: 1 addition & 0 deletions packages/vite/src/node/server/middlewares/indexHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ const devHtmlHook: IndexHtmlTransformHook = async (
) => {
const { config, moduleGraph, watcher } = server!
const base = config.base || '/'
htmlPath = decodeURI(htmlPath)

let proxyModulePath: string
let proxyModuleUrl: string
Expand Down
10 changes: 10 additions & 0 deletions playground/html/__tests__/html.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,13 @@ describe('side-effects', () => {
expect(browserLogs).toContain('message from sideEffects script')
})
})

describe('special character', () => {
beforeAll(async () => {
await page.goto(viteTestUrl + '/a á.html')
})

test('should fetch html proxy', async () => {
expect(browserLogs).toContain('special character')
})
})
5 changes: 5 additions & 0 deletions playground/html/a á.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>Special Character</h1>

<script type="module">
console.log('special character')
</script>
1 change: 1 addition & 0 deletions playground/html/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default defineConfig({
importmapOrder: resolve(__dirname, 'importmapOrder.html'),
env: resolve(__dirname, 'env.html'),
sideEffects: resolve(__dirname, 'side-effects/index.html'),
'a á': resolve(__dirname, 'a á.html'),
},
},
},
Expand Down