Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored and astrobot-houston committed Dec 19, 2023
1 parent 5ae6578 commit c32e607
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions packages/astro/src/core/redirects/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export function redirectRouteGenerate(redirectRoute: RouteData, data: Params): s
return routeData?.generate(data) || routeData?.pathname || '/';
} else if (typeof route === 'string') {
// TODO: this logic is duplicated between here and manifest/create.ts
let target = route
let target = route;
for (const param of Object.keys(data)) {
const paramValue = data[param]!
target = target.replace(`[${param}]`, paramValue)
target = target.replace(`[...${param}]`, paramValue)
const paramValue = data[param]!;
target = target.replace(`[${param}]`, paramValue);
target = target.replace(`[...${param}]`, paramValue);
}
return target
return target;
} else if (typeof route === 'undefined') {
return '/';
}
Expand Down
6 changes: 3 additions & 3 deletions packages/astro/test/redirects.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,21 @@ describe('Astro.redirect', () => {
const app = await fixture.loadTestAdapterApp();
const request = new Request('http://example.com/source/x');
const response = await app.render(request);
expect(response.headers.get("Location")).to.equal("/not-verbatim/target1/x");
expect(response.headers.get('Location')).to.equal('/not-verbatim/target1/x');
});

it('Forwards params to the target path - multiple params', async () => {
const app = await fixture.loadTestAdapterApp();
const request = new Request('http://example.com/source/x/y');
const response = await app.render(request);
expect(response.headers.get("Location")).to.equal("/not-verbatim/target2/x/y");
expect(response.headers.get('Location')).to.equal('/not-verbatim/target2/x/y');
});

it('Forwards params to the target path - spread param', async () => {
const app = await fixture.loadTestAdapterApp();
const request = new Request('http://example.com/source/x/y/z');
const response = await app.render(request);
expect(response.headers.get("Location")).to.equal("/not-verbatim/target3/x/y/z");
expect(response.headers.get('Location')).to.equal('/not-verbatim/target3/x/y/z');
});
});
});
Expand Down

0 comments on commit c32e607

Please sign in to comment.