Skip to content

Commit

Permalink
Use forEach instead of map
Browse files Browse the repository at this point in the history
We’re not returning anything so map is not needed
  • Loading branch information
scottybollinger committed Sep 1, 2020
1 parent 04a2e8d commit 435677f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const reTokens = /<(.*?)>/g;
export const formatRoute = (routePath: string, params: ParamsObject) => {
const tokens = {} as { [key: string]: string };

Object.entries(params).map(([paramName, paramValue]) => {
Object.entries(params).forEach(([paramName, paramValue]) => {
const paramRegex = new RegExp('(/|\\(|\\)|^):' + paramName + '(/|\\)|\\(|$)');
routePath = routePath.replace(paramRegex, (_, g1, g2) => {
tokens[paramName] = encodeURIComponent(paramValue);
Expand Down

0 comments on commit 435677f

Please sign in to comment.