-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 404 routing logic to Netlify redirects file (#4274)
* Add 404 routing logic to Netlify redirects file * changeset
- Loading branch information
Showing
5 changed files
with
59 additions
and
0 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 @@ | ||
--- | ||
'@astrojs/netlify': patch | ||
--- | ||
|
||
Adds 404 routing logic to Netlify redirects file |
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,27 @@ | ||
import { expect } from 'chai'; | ||
import netlifyAdapter from '../../dist/index.js'; | ||
import { loadFixture, testIntegration } from './test-utils.js'; | ||
|
||
describe('404 page', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: new URL('./fixtures/404/', import.meta.url).toString(), | ||
output: 'server', | ||
adapter: netlifyAdapter({ | ||
dist: new URL('./fixtures/404/dist/', import.meta.url), | ||
}), | ||
site: `http://example.com`, | ||
integrations: [testIntegration()], | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('404 route is included in the redirect file', async () => { | ||
const redir = await fixture.readFile('/_redirects'); | ||
const expr = new RegExp("/* /.netlify/functions/entry 404"); | ||
expect(redir).to.match(expr); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/integrations/netlify/test/functions/fixtures/404/src/pages/404.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,11 @@ | ||
--- | ||
--- | ||
<html> | ||
<head> | ||
<title>Not found</title> | ||
</head> | ||
<body> | ||
<h1>Not found</h1> | ||
</body> | ||
</html> |
11 changes: 11 additions & 0 deletions
11
packages/integrations/netlify/test/functions/fixtures/404/src/pages/index.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,11 @@ | ||
--- | ||
--- | ||
<html> | ||
<head> | ||
<title>Testing</title> | ||
</head> | ||
<body> | ||
<h1>Testing</h1> | ||
</body> | ||
</html> |