Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored and github-actions[bot] committed Apr 15, 2022
1 parent e0f838c commit abcee7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
20 changes: 8 additions & 12 deletions packages/astro/src/core/routing/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,13 @@ export function getParams(array: string[]) {
*/
export function stringifyParams(params: Params) {
// validate parameter values then stringify each value
const validatedParams = Object.entries(params)
.reduce((acc, next) => {
validateGetStaticPathsParameter(next);
const [key, value] = next;
acc[key] = `${value}`;
return acc;
}, {} as Params);
const validatedParams = Object.entries(params).reduce((acc, next) => {
validateGetStaticPathsParameter(next);
const [key, value] = next;
acc[key] = `${value}`;
return acc;
}, {} as Params);

// Always sort keys before stringifying to make sure objects match regardless of parameter ordering
return JSON.stringify(
validatedParams,
Object.keys(params).sort()
);
}
return JSON.stringify(validatedParams, Object.keys(params).sort());
}
4 changes: 2 additions & 2 deletions packages/astro/test/astro-get-static-paths.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ describe('getStaticPaths - route params type validation', () => {
// route provided with { params: { year: 2022, slug: "post-2" }}
const res = await fixture.fetch('/blog/2022/post-2');
expect(res.status).to.equal(200);
})
})
});
});

0 comments on commit abcee7c

Please sign in to comment.