Skip to content

Commit

Permalink
fix: only append matched value if key ends with "/" char;
Browse files Browse the repository at this point in the history
- Related #26
  • Loading branch information
lukeed committed Mar 6, 2023
1 parent 2ad02bf commit 5d9601d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ export function walk(name: string, mapping: Mapping, input: string, options?: t.

/** @note: mutates! */
export function injects(items: string[], value: string): void {
let i=0, len=items.length, rgx=/[*]/g, tmp: string;
let i=0, len=items.length, tmp: string;
let rgx1=/[*]/g, rgx2 = /[/]$/;

for (; i < len; i++) {
items[i] = rgx.test(tmp = items[i])
? tmp.replace(rgx, value)
: (tmp+value);
items[i] = rgx1.test(tmp = items[i])
? tmp.replace(rgx1, value)
: rgx2.test(tmp)
? (tmp+value)
: tmp;
}
}

Expand Down

0 comments on commit 5d9601d

Please sign in to comment.