mirror of
https://github.com/withastro/astro.git
synced 2025-03-10 23:01:26 -05:00
fix(vercel): clear artifacts from redirects (#9287)
This commit is contained in:
parent
9c1efc8648
commit
76a8ed20c5
2 changed files with 6 additions and 7 deletions
|
@ -21,8 +21,7 @@ function getMatchPattern(segments: RoutePart[][]) {
|
|||
.map((segment) => {
|
||||
return segment[0].spread
|
||||
? '(?:\\/(.*?))?'
|
||||
: '\\/' +
|
||||
segment
|
||||
: segment
|
||||
.map((part) => {
|
||||
if (part)
|
||||
return part.dynamic
|
||||
|
|
|
@ -32,15 +32,15 @@ describe('Redirects', () => {
|
|||
it('define static routes', async () => {
|
||||
const config = await getConfig();
|
||||
|
||||
const oneRoute = config.routes.find((r) => r.src === '/\\/one');
|
||||
const oneRoute = config.routes.find((r) => r.src === '/one');
|
||||
expect(oneRoute.headers.Location).to.equal('/');
|
||||
expect(oneRoute.status).to.equal(301);
|
||||
|
||||
const twoRoute = config.routes.find((r) => r.src === '/\\/two');
|
||||
const twoRoute = config.routes.find((r) => r.src === '/two');
|
||||
expect(twoRoute.headers.Location).to.equal('/');
|
||||
expect(twoRoute.status).to.equal(301);
|
||||
|
||||
const threeRoute = config.routes.find((r) => r.src === '/\\/three');
|
||||
const threeRoute = config.routes.find((r) => r.src === '/three');
|
||||
expect(threeRoute.headers.Location).to.equal('/');
|
||||
expect(threeRoute.status).to.equal(302);
|
||||
});
|
||||
|
@ -48,7 +48,7 @@ describe('Redirects', () => {
|
|||
it('defines dynamic routes', async () => {
|
||||
const config = await getConfig();
|
||||
|
||||
const blogRoute = config.routes.find((r) => r.src.startsWith('/\\/blog'));
|
||||
const blogRoute = config.routes.find((r) => r.src.startsWith('/blog'));
|
||||
expect(blogRoute).to.not.be.undefined;
|
||||
expect(blogRoute.headers.Location.startsWith('/team/articles')).to.equal(true);
|
||||
expect(blogRoute.status).to.equal(301);
|
||||
|
@ -57,7 +57,7 @@ describe('Redirects', () => {
|
|||
it('define trailingSlash redirect for sub pages', async () => {
|
||||
const config = await getConfig();
|
||||
|
||||
const subpathRoute = config.routes.find((r) => r.src === '/\\/subpage');
|
||||
const subpathRoute = config.routes.find((r) => r.src === '/subpage');
|
||||
expect(subpathRoute).to.not.be.undefined;
|
||||
expect(subpathRoute.headers.Location).to.equal('/subpage/');
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue