fix(middleware): undo config's path to URL encoding (#8614)
* fix(middleware): undo config's path to URL encoding * add changeset * middleware-dev => "middleware space"
This commit is contained in:
parent
b4034aabea
commit
4398e92987
20 changed files with 14 additions and 9 deletions
5
.changeset/tidy-kiwis-lick.md
Normal file
5
.changeset/tidy-kiwis-lick.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fixed an issue where spaces and unicode characters in project path prevented middleware from running.
|
|
@ -25,7 +25,7 @@ export function vitePluginMiddleware(
|
|||
async resolveId(id) {
|
||||
if (id === MIDDLEWARE_MODULE_ID) {
|
||||
const middlewareId = await this.resolve(
|
||||
`${opts.settings.config.srcDir.pathname}/${MIDDLEWARE_PATH_SEGMENT_NAME}`
|
||||
`${decodeURI(opts.settings.config.srcDir.pathname)}${MIDDLEWARE_PATH_SEGMENT_NAME}`
|
||||
);
|
||||
if (middlewareId) {
|
||||
resolvedMiddlewareId = middlewareId.id;
|
||||
|
|
|
@ -12,7 +12,7 @@ export async function loadMiddleware(
|
|||
srcDir: AstroSettings['config']['srcDir']
|
||||
) {
|
||||
// can't use node Node.js builtins
|
||||
let middlewarePath = srcDir.pathname + '/' + MIDDLEWARE_PATH_SEGMENT_NAME;
|
||||
let middlewarePath = `${decodeURI(srcDir.pathname)}${MIDDLEWARE_PATH_SEGMENT_NAME}`;
|
||||
try {
|
||||
const module = await moduleLoader.import(middlewarePath);
|
||||
return module;
|
||||
|
|
|
@ -8,7 +8,7 @@ describe('Adapter', () => {
|
|||
it("should error if the adapter doesn't support edge middleware", async () => {
|
||||
try {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/middleware-dev/',
|
||||
root: './fixtures/middleware space/',
|
||||
output: 'server',
|
||||
build: {
|
||||
excludeMiddleware: true,
|
||||
|
@ -32,7 +32,7 @@ describe('Adapter', () => {
|
|||
it("should error if the adapter doesn't support split build", async () => {
|
||||
try {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/middleware-dev/',
|
||||
root: './fixtures/middleware space/',
|
||||
output: 'server',
|
||||
build: {
|
||||
split: true,
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('Middleware in DEV mode', () => {
|
|||
|
||||
before(async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/middleware-dev/',
|
||||
root: './fixtures/middleware space/',
|
||||
});
|
||||
devServer = await fixture.startDevServer();
|
||||
});
|
||||
|
@ -116,7 +116,7 @@ describe('Middleware API in PROD mode, SSR', () => {
|
|||
|
||||
before(async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/middleware-dev/',
|
||||
root: './fixtures/middleware space/',
|
||||
output: 'server',
|
||||
adapter: testAdapter({}),
|
||||
});
|
||||
|
@ -223,7 +223,7 @@ describe('Middleware API in PROD mode, SSR', () => {
|
|||
|
||||
it('the integration should receive the path to the middleware', async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/middleware-dev/',
|
||||
root: './fixtures/middleware space/',
|
||||
output: 'server',
|
||||
build: {
|
||||
excludeMiddleware: true,
|
||||
|
@ -275,7 +275,7 @@ describe('Middleware, split middleware option', () => {
|
|||
|
||||
before(async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/middleware-dev/',
|
||||
root: './fixtures/middleware space/',
|
||||
output: 'server',
|
||||
build: {
|
||||
excludeMiddleware: true,
|
||||
|
|
|
@ -2847,7 +2847,7 @@ importers:
|
|||
specifier: workspace:*
|
||||
version: link:../../..
|
||||
|
||||
packages/astro/test/fixtures/middleware-dev:
|
||||
packages/astro/test/fixtures/middleware space:
|
||||
dependencies:
|
||||
astro:
|
||||
specifier: workspace:*
|
||||
|
|
Loading…
Reference in a new issue