Skip to content

Commit 9fd31e0

Browse files
authored
Add trailing: false tests (#428)
1 parent 1e796b5 commit 9fd31e0

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

src/cases.spec.ts

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,109 @@ export const MATCH_TESTS: MatchTestSet[] = [
478478
],
479479
},
480480

481+
/**
482+
* Strict trailing delimiter.
483+
*/
484+
{
485+
path: "/test",
486+
options: {
487+
trailing: false,
488+
},
489+
tests: [
490+
{
491+
input: "/test",
492+
expected: { path: "/test", params: {} },
493+
},
494+
{ input: "/test/", expected: false },
495+
],
496+
},
497+
{
498+
path: "/test/",
499+
options: {
500+
trailing: false,
501+
},
502+
tests: [
503+
{
504+
input: "/test/",
505+
expected: { path: "/test/", params: {} },
506+
},
507+
{ input: "/test", expected: false },
508+
],
509+
},
510+
{
511+
path: "/:test",
512+
options: {
513+
trailing: false,
514+
},
515+
tests: [
516+
{
517+
input: "/route",
518+
expected: { path: "/route", params: { test: "route" } },
519+
},
520+
{ input: "/route/", expected: false },
521+
],
522+
},
523+
{
524+
path: "/*path",
525+
options: {
526+
trailing: false,
527+
},
528+
tests: [
529+
{
530+
input: "/route",
531+
expected: { path: "/route", params: { path: ["route"] } },
532+
},
533+
{
534+
input: "/route/nested",
535+
expected: {
536+
path: "/route/nested",
537+
params: { path: ["route", "nested"] },
538+
},
539+
},
540+
{
541+
input: "/route/nested/",
542+
expected: {
543+
path: "/route/nested/",
544+
params: { path: ["route", "nested", ""] },
545+
},
546+
},
547+
],
548+
},
549+
{
550+
path: "/test",
551+
options: {
552+
trailing: false,
553+
end: false,
554+
},
555+
tests: [
556+
{
557+
input: "/test",
558+
expected: { path: "/test", params: {} },
559+
},
560+
{
561+
input: "/test/route",
562+
expected: { path: "/test", params: {} },
563+
},
564+
],
565+
},
566+
{
567+
path: "{/:test}/bar",
568+
options: {
569+
trailing: false,
570+
},
571+
tests: [
572+
{
573+
input: "/bar",
574+
expected: { path: "/bar", params: {} },
575+
},
576+
{
577+
input: "/foo/bar",
578+
expected: { path: "/foo/bar", params: { test: "foo" } },
579+
},
580+
{ input: "/foo/bar/", expected: false },
581+
],
582+
},
583+
481584
/**
482585
* Non-ending mode.
483586
*/

0 commit comments

Comments
 (0)