Skip to content

Commit e5e32a7

Browse files
committed
align to h3
1 parent 1a19690 commit e5e32a7

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

.changeset/quick-cloths-repair.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44
---
55

66
chore: bump to h3 v2 rc 20
7+
8+
`requestHandler` now translates the `URIError` thrown by `new H3Event(request)` on malformed percent-encoded request paths (e.g. `/%80`, `/%FF`, `/%E0%A4`) into a 400 Bad Request response. Previously these inputs caused an uncaught error that surfaced as a 500.
9+
10+
`getCookies()` return type narrows to `Record<string, string | undefined>` matching the corrected h3 v2 rc.20 type. Runtime behavior is unchanged.

packages/start-server-core/src/request-response.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,9 @@ export function setResponseStatus(code?: number, text?: string): void {
293293
* const cookies = getCookies()
294294
* ```
295295
*/
296-
export function getCookies(): Record<string, string> {
296+
export function getCookies(): Record<string, string | undefined> {
297297
const event = getH3Event()
298-
const cookies = h3_parseCookies(event)
299-
const definedCookies = Object.create(null) as Record<string, string>
300-
301-
for (const [name, value] of Object.entries(cookies)) {
302-
if (value !== undefined) {
303-
definedCookies[name] = value
304-
}
305-
}
306-
307-
return definedCookies
298+
return h3_parseCookies(event)
308299
}
309300

310301
/**
@@ -316,7 +307,7 @@ export function getCookies(): Record<string, string> {
316307
* ```
317308
*/
318309
export function getCookie(name: string): string | undefined {
319-
return getCookies()[name] || undefined
310+
return getCookies()[name]
320311
}
321312

322313
/**

0 commit comments

Comments
 (0)