Skip to content

Commit 0e2c900

Browse files
authored
chore: bump to h3 v2 rc.20 (#7140)
1 parent 9797eac commit 0e2c900

8 files changed

Lines changed: 113 additions & 77 deletions

File tree

.changeset/quick-cloths-repair.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@tanstack/start-server-core': patch
3+
'@tanstack/router-core': patch
4+
---
5+
6+
chore: bump to h3 v2-rc.20

e2e/react-start/basic-test-suite/src/special-characters.spec.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -187,31 +187,35 @@ test.describe('Unicode route rendering', () => {
187187
})
188188

189189
test.describe('malformed paths', () => {
190+
const malformedPathnames = [
191+
'/specialChars/malformed/%E0%A4',
192+
'/specialChars/malformed/%80',
193+
'/specialChars/malformed/%FF',
194+
]
195+
190196
test.use({
191197
whitelistErrors: [
192198
'Failed to load resource: the server responded with a status of 404',
193199
'Failed to load resource: the server responded with a status of 400 (Bad Request)',
194200
],
195201
})
196202

197-
test('un-matched malformed paths should return not found on direct navigation', async ({
198-
page,
199-
}) => {
200-
const res = await page.goto('/specialChars/malformed/%E0%A4')
201-
202-
await page.waitForLoadState(`load`)
203-
204-
// in spa mode this is caught and handled at server level
205-
if (!isSpaMode) {
206-
expect(res!.status()).toBe(404)
207-
208-
await expect(
209-
page.getByTestId('default-not-found-component'),
210-
).toBeInViewport()
211-
} else {
212-
expect(res!.status()).toBe(400)
213-
}
214-
})
203+
for (const pathname of malformedPathnames) {
204+
test(`un-matched malformed path "${pathname}" should return bad request on direct navigation`, async ({
205+
page,
206+
}) => {
207+
const res = await page.goto(pathname)
208+
209+
await page.waitForLoadState(`load`)
210+
211+
// in spa mode this is caught and handled at server level
212+
if (!isSpaMode) {
213+
expect(res!.status()).toBe(400)
214+
} else {
215+
expect(res!.status()).toBe(400)
216+
}
217+
})
218+
}
215219

216220
test('malformed path params should return not found on router link', async ({
217221
page,

e2e/solid-start/basic-test-suite/src/special-characters.spec.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -175,31 +175,35 @@ test.describe('Unicode route rendering', () => {
175175
})
176176

177177
test.describe('malformed paths', () => {
178+
const malformedPathnames = [
179+
'/specialChars/malformed/%E0%A4',
180+
'/specialChars/malformed/%80',
181+
'/specialChars/malformed/%FF',
182+
]
183+
178184
test.use({
179185
whitelistErrors: [
180186
'Failed to load resource: the server responded with a status of 404',
181187
'Failed to load resource: the server responded with a status of 400 (Bad Request)',
182188
],
183189
})
184190

185-
test('un-matched malformed paths should return not found on direct navigation', async ({
186-
page,
187-
}) => {
188-
const res = await page.goto('/specialChars/malformed/%E0%A4')
189-
190-
await page.waitForLoadState(`load`)
191-
192-
// in spa mode this is caught and handled at server level
193-
if (!isSpaMode) {
194-
expect(res!.status()).toBe(404)
195-
196-
await expect(
197-
page.getByTestId('default-not-found-component'),
198-
).toBeInViewport()
199-
} else {
200-
expect(res!.status()).toBe(400)
201-
}
202-
})
191+
for (const pathname of malformedPathnames) {
192+
test(`un-matched malformed path "${pathname}" should return bad request on direct navigation`, async ({
193+
page,
194+
}) => {
195+
const res = await page.goto(pathname)
196+
197+
await page.waitForLoadState(`load`)
198+
199+
// in spa mode this is caught and handled at server level
200+
if (!isSpaMode) {
201+
expect(res!.status()).toBe(400)
202+
} else {
203+
expect(res!.status()).toBe(400)
204+
}
205+
})
206+
}
203207

204208
test('malformed path params should return not found on router link', async ({
205209
page,

e2e/vue-start/basic-test-suite/src/special-characters.spec.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -175,31 +175,35 @@ test.describe('Unicode route rendering', () => {
175175
})
176176

177177
test.describe('malformed paths', () => {
178+
const malformedPathnames = [
179+
'/specialChars/malformed/%E0%A4',
180+
'/specialChars/malformed/%80',
181+
'/specialChars/malformed/%FF',
182+
]
183+
178184
test.use({
179185
whitelistErrors: [
180186
'Failed to load resource: the server responded with a status of 404',
181187
'Failed to load resource: the server responded with a status of 400 (Bad Request)',
182188
],
183189
})
184190

185-
test('un-matched malformed paths should return not found on direct navigation', async ({
186-
page,
187-
}) => {
188-
const res = await page.goto('/specialChars/malformed/%E0%A4')
189-
190-
await page.waitForLoadState(`load`)
191-
192-
// in spa mode this is caught and handled at server level
193-
if (!isSpaMode) {
194-
expect(res!.status()).toBe(404)
195-
196-
await expect(
197-
page.getByTestId('default-not-found-component'),
198-
).toBeInViewport()
199-
} else {
200-
expect(res!.status()).toBe(400)
201-
}
202-
})
191+
for (const pathname of malformedPathnames) {
192+
test(`un-matched malformed path "${pathname}" should return bad request on direct navigation`, async ({
193+
page,
194+
}) => {
195+
const res = await page.goto(pathname)
196+
197+
await page.waitForLoadState(`load`)
198+
199+
// in spa mode this is caught and handled at server level
200+
if (!isSpaMode) {
201+
expect(res!.status()).toBe(400)
202+
} else {
203+
expect(res!.status()).toBe(400)
204+
}
205+
})
206+
}
203207

204208
test('malformed path params should return not found on router link', async ({
205209
page,

packages/router-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
},
184184
"dependencies": {
185185
"@tanstack/history": "workspace:*",
186-
"cookie-es": "^2.0.0",
186+
"cookie-es": "^3.0.0",
187187
"seroval": "^1.5.0",
188188
"seroval-plugins": "^1.5.0"
189189
},

packages/start-server-core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@
8282
"@tanstack/router-core": "workspace:*",
8383
"@tanstack/start-client-core": "workspace:*",
8484
"@tanstack/start-storage-context": "workspace:*",
85-
"h3-v2": "npm:h3@2.0.1-rc.16",
85+
"h3-v2": "npm:h3@2.0.1-rc.20",
8686
"seroval": "^1.5.0"
8787
},
8888
"devDependencies": {
8989
"@standard-schema/spec": "^1.0.0",
9090
"@tanstack/intent": "^0.0.14",
91-
"cookie-es": "^2.0.0",
91+
"cookie-es": "^3.0.0",
9292
"fetchdts": "^0.1.6",
9393
"vite": "*",
9494
"@types/node": ">=20"

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,18 @@ export function requestHandler<TRegister = unknown>(
122122
handler: RequestHandler<TRegister>,
123123
) {
124124
return (request: Request, requestOpts: any): Promise<Response> | Response => {
125-
const h3Event = new H3Event(request)
125+
let h3Event: H3Event
126+
try {
127+
h3Event = new H3Event(request)
128+
} catch (error) {
129+
if (error instanceof URIError) {
130+
return new Response(null, {
131+
status: 400,
132+
statusText: 'Bad Request',
133+
})
134+
}
135+
throw error
136+
}
126137

127138
const response = eventStorage.run({ h3Event }, () =>
128139
handler(request, requestOpts),
@@ -284,7 +295,16 @@ export function setResponseStatus(code?: number, text?: string): void {
284295
*/
285296
export function getCookies(): Record<string, string> {
286297
const event = getH3Event()
287-
return h3_parseCookies(event)
298+
const cookies = h3_parseCookies(event)
299+
const definedCookies: Record<string, string> = Object.create(null)
300+
301+
for (const [name, value] of Object.entries(cookies)) {
302+
if (value !== undefined) {
303+
definedCookies[name] = value
304+
}
305+
}
306+
307+
return definedCookies
288308
}
289309

290310
/**
@@ -296,7 +316,7 @@ export function getCookies(): Record<string, string> {
296316
* ```
297317
*/
298318
export function getCookie(name: string): string | undefined {
299-
return getCookies()[name] || undefined
319+
return getCookies()[name]
300320
}
301321

302322
/**

pnpm-lock.yaml

Lines changed: 15 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)