Skip to content

Commit

Permalink
Separate union case
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Mar 31, 2024
1 parent eb11ac0 commit e8ece8d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,17 @@ export const matchToUrl = (matcher: Matcher, params: Params = {}): string => {

const { union } = test;

if (union == null) {
object[key] = param;
continue;
}

if (typeof param === "string") {
if (union == null || union.includes(param)) {
if (union.includes(param)) {
object[key] = param;
}
} else {
object[key] =
union == null ? param : param.filter((item) => union.includes(item));
object[key] = param.filter((item) => union.includes(item));
}
}

Expand Down

0 comments on commit e8ece8d

Please sign in to comment.