Skip to content

Commit

Permalink
fix(vercel): clear artifacts from redirects (#9287)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilnasy authored Dec 8, 2023
1 parent 9c1efc8 commit 76a8ed2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/integrations/vercel/src/lib/redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ function getMatchPattern(segments: RoutePart[][]) {
.map((segment) => {
return segment[0].spread
? '(?:\\/(.*?))?'
: '\\/' +
segment
: segment
.map((part) => {
if (part)
return part.dynamic
Expand Down
10 changes: 5 additions & 5 deletions packages/integrations/vercel/test/redirects.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ 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);
});

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);
Expand All @@ -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/');
});
Expand Down

0 comments on commit 76a8ed2

Please sign in to comment.