-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): handle encoded characters when matching routes (#5836)
Co-authored-by: Nate Moore <[email protected]>
- Loading branch information
1 parent
ae8a012
commit 63a6ceb
Showing
8 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fix route matching when path includes special characters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import nodejs from '../dist/index.js'; | ||
import { loadFixture, createRequestAndResponse } from './test-utils.js'; | ||
import { expect } from 'chai'; | ||
|
||
describe('Encoded Pathname', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/encoded/', | ||
output: 'server', | ||
adapter: nodejs({ mode: 'middleware' }), | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('Can get an Astro file', async () => { | ||
const { handler } = await import('./fixtures/encoded/dist/server/entry.mjs'); | ||
let { req, res, text } = createRequestAndResponse({ | ||
url: '/什么', | ||
}); | ||
|
||
handler(req, res); | ||
req.send(); | ||
|
||
const html = await text(); | ||
expect(html).to.include('什么</h1>'); | ||
}); | ||
|
||
it('Can get a Markdown file', async () => { | ||
const { handler } = await import('./fixtures/encoded/dist/server/entry.mjs'); | ||
|
||
let { req, res, text } = createRequestAndResponse({ | ||
url: '/blog/什么', | ||
}); | ||
|
||
handler(req, res); | ||
req.send(); | ||
|
||
const html = await text(); | ||
expect(html).to.include('什么</h1>'); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/integrations/node/test/fixtures/encoded/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@test/nodejs-encoded", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/node": "workspace:*" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/integrations/node/test/fixtures/encoded/src/pages/blog/什么.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# 什么 |
1 change: 1 addition & 0 deletions
1
packages/integrations/node/test/fixtures/encoded/src/pages/什么.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>什么</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.