Skip to content

Commit 578b072

Browse files
committed
Test loose can be disabled
1 parent 01086a0 commit 578b072

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/index.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2771,6 +2771,26 @@ const MATCH_TESTS: MatchTestSet[] = [
27712771
},
27722772
],
27732773
},
2774+
2775+
/**
2776+
* No loose.
2777+
*/
2778+
{
2779+
path: "/test",
2780+
options: { loose: "" },
2781+
tests: [
2782+
{
2783+
input: "/test",
2784+
matches: ["/test"],
2785+
expected: { path: "/test", index: 0, params: {} },
2786+
},
2787+
{
2788+
input: "//test",
2789+
matches: null,
2790+
expected: false,
2791+
},
2792+
],
2793+
},
27742794
];
27752795

27762796
/**

src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,10 +634,7 @@ function tokensToRegexp(
634634
}
635635
}
636636

637-
if (trailing) {
638-
pattern += `(?:${stringify(data.delimiter)})${loose ? "?" : ""}`;
639-
}
640-
637+
if (trailing) pattern += `(?:${stringify(data.delimiter)})?`;
641638
pattern += end ? "$" : `(?=${escape(data.delimiter)}|$)`;
642639

643640
return new RegExp(pattern, flags(options));

0 commit comments

Comments
 (0)