@@ -1043,35 +1043,6 @@ const MATCH_TESTS: MatchTestSet[] = [
1043
1043
] ,
1044
1044
} ,
1045
1045
1046
- /**
1047
- * Arrays of simple paths.
1048
- */
1049
- {
1050
- path : [ "/one" , "/two" ] ,
1051
- tests : [
1052
- {
1053
- input : "/one" ,
1054
- matches : [ "/one" ] ,
1055
- expected : { path : "/one" , index : 0 , params : { } } ,
1056
- } ,
1057
- {
1058
- input : "/two" ,
1059
- matches : [ "/two" ] ,
1060
- expected : { path : "/two" , index : 0 , params : { } } ,
1061
- } ,
1062
- {
1063
- input : "/three" ,
1064
- matches : null ,
1065
- expected : false ,
1066
- } ,
1067
- {
1068
- input : "/one/two" ,
1069
- matches : null ,
1070
- expected : false ,
1071
- } ,
1072
- ] ,
1073
- } ,
1074
-
1075
1046
/**
1076
1047
* Optional.
1077
1048
*/
@@ -1961,132 +1932,6 @@ const MATCH_TESTS: MatchTestSet[] = [
1961
1932
] ,
1962
1933
} ,
1963
1934
1964
- /**
1965
- * Regexps.
1966
- */
1967
- {
1968
- path : / .* / ,
1969
- tests : [
1970
- {
1971
- input : "/match/anything" ,
1972
- matches : [ "/match/anything" ] ,
1973
- expected : { path : "/match/anything" , index : 0 , params : { } } ,
1974
- } ,
1975
- ] ,
1976
- } ,
1977
- {
1978
- path : / ( .* ) / ,
1979
- tests : [
1980
- {
1981
- input : "/match/anything" ,
1982
- matches : [ "/match/anything" , "/match/anything" ] ,
1983
- expected : {
1984
- path : "/match/anything" ,
1985
- index : 0 ,
1986
- params : { "0" : "/match/anything" } ,
1987
- } ,
1988
- } ,
1989
- ] ,
1990
- } ,
1991
- {
1992
- path : / \/ ( \d + ) / ,
1993
- tests : [
1994
- {
1995
- input : "/abc" ,
1996
- matches : null ,
1997
- expected : false ,
1998
- } ,
1999
- {
2000
- input : "/123" ,
2001
- matches : [ "/123" , "123" ] ,
2002
- expected : { path : "/123" , index : 0 , params : { "0" : "123" } } ,
2003
- } ,
2004
- ] ,
2005
- } ,
2006
-
2007
- /**
2008
- * Mixed inputs.
2009
- */
2010
- {
2011
- path : [ "/one" , / \/ t w o / ] ,
2012
- tests : [
2013
- {
2014
- input : "/one" ,
2015
- matches : [ "/one" ] ,
2016
- expected : { path : "/one" , index : 0 , params : { } } ,
2017
- } ,
2018
- {
2019
- input : "/two" ,
2020
- matches : [ "/two" ] ,
2021
- expected : { path : "/two" , index : 0 , params : { } } ,
2022
- } ,
2023
- {
2024
- input : "/three" ,
2025
- matches : null ,
2026
- expected : false ,
2027
- } ,
2028
- ] ,
2029
- } ,
2030
- {
2031
- path : [ "/:test(\\d+)" , / ( .* ) / ] ,
2032
- tests : [
2033
- {
2034
- input : "/123" ,
2035
- matches : [ "/123" , "123" , undefined ] ,
2036
- expected : { path : "/123" , index : 0 , params : { test : "123" } } ,
2037
- } ,
2038
- {
2039
- input : "/abc" ,
2040
- matches : [ "/abc" , undefined , "/abc" ] ,
2041
- expected : { path : "/abc" , index : 0 , params : { "0" : "/abc" } } ,
2042
- } ,
2043
- ] ,
2044
- } ,
2045
-
2046
- /**
2047
- * Correct names and indexes.
2048
- */
2049
- {
2050
- path : [ "/:test" , "/route/:test2" ] ,
2051
- tests : [
2052
- {
2053
- input : "/test" ,
2054
- matches : [ "/test" , "test" , undefined ] ,
2055
- expected : { path : "/test" , index : 0 , params : { test : "test" } } ,
2056
- } ,
2057
- {
2058
- input : "/route/test" ,
2059
- matches : [ "/route/test" , undefined , "test" ] ,
2060
- expected : { path : "/route/test" , index : 0 , params : { test2 : "test" } } ,
2061
- } ,
2062
- ] ,
2063
- } ,
2064
- {
2065
- path : [ / ^ \/ ( [ ^ / ] + ) $ / , / ^ \/ r o u t e \/ ( [ ^ / ] + ) $ / ] ,
2066
- tests : [
2067
- {
2068
- input : "/test" ,
2069
- matches : [ "/test" , "test" , undefined ] ,
2070
- expected : { path : "/test" , index : 0 , params : { 0 : "test" } } ,
2071
- } ,
2072
- {
2073
- input : "/route/test" ,
2074
- matches : [ "/route/test" , undefined , "test" ] ,
2075
- expected : { path : "/route/test" , index : 0 , params : { 0 : "test" } } ,
2076
- } ,
2077
- ] ,
2078
- } ,
2079
- {
2080
- path : / (?: .* ) / ,
2081
- tests : [
2082
- {
2083
- input : "/anything/you/want" ,
2084
- matches : [ "/anything/you/want" ] ,
2085
- expected : { path : "/anything/you/want" , index : 0 , params : { } } ,
2086
- } ,
2087
- ] ,
2088
- } ,
2089
-
2090
1935
/**
2091
1936
* Escaped characters.
2092
1937
*/
@@ -2775,82 +2620,6 @@ const MATCH_TESTS: MatchTestSet[] = [
2775
2620
] ,
2776
2621
} ,
2777
2622
2778
- /**
2779
- * Named capturing groups.
2780
- */
2781
- {
2782
- path : / \/ (?< groupname > .+ ) / ,
2783
- tests : [
2784
- {
2785
- input : "/foo" ,
2786
- matches : [ "/foo" , "foo" ] ,
2787
- expected : { path : "/foo" , index : 0 , params : { groupname : "foo" } } ,
2788
- } ,
2789
- ] ,
2790
- } ,
2791
- {
2792
- path : / \/ (?< test > .* ) .(?< format > h t m l | j s o n ) / ,
2793
- tests : [
2794
- {
2795
- input : "/route" ,
2796
- matches : null ,
2797
- expected : false ,
2798
- } ,
2799
- {
2800
- input : "/route.txt" ,
2801
- matches : null ,
2802
- expected : false ,
2803
- } ,
2804
- {
2805
- input : "/route.html" ,
2806
- matches : [ "/route.html" , "route" , "html" ] ,
2807
- expected : {
2808
- path : "/route.html" ,
2809
- index : 0 ,
2810
- params : { test : "route" , format : "html" } ,
2811
- } ,
2812
- } ,
2813
- {
2814
- input : "/route.json" ,
2815
- matches : [ "/route.json" , "route" , "json" ] ,
2816
- expected : {
2817
- path : "/route.json" ,
2818
- index : 0 ,
2819
- params : { test : "route" , format : "json" } ,
2820
- } ,
2821
- } ,
2822
- ] ,
2823
- } ,
2824
- {
2825
- path : / \/ ( .+ ) \/ (?< groupname > .+ ) \/ ( .+ ) / ,
2826
- tests : [
2827
- {
2828
- input : "/test" ,
2829
- matches : null ,
2830
- expected : false ,
2831
- } ,
2832
- {
2833
- input : "/test/testData" ,
2834
- matches : null ,
2835
- expected : false ,
2836
- } ,
2837
- {
2838
- input : "/test/testData/extraStuff" ,
2839
- matches : [
2840
- "/test/testData/extraStuff" ,
2841
- "test" ,
2842
- "testData" ,
2843
- "extraStuff" ,
2844
- ] ,
2845
- expected : {
2846
- path : "/test/testData/extraStuff" ,
2847
- index : 0 ,
2848
- params : { 0 : "test" , 1 : "extraStuff" , groupname : "testData" } ,
2849
- } ,
2850
- } ,
2851
- ] ,
2852
- } ,
2853
-
2854
2623
/**
2855
2624
* https://github.com/pillarjs/path-to-regexp/pull/270
2856
2625
*/
@@ -2952,23 +2721,8 @@ const MATCH_TESTS: MatchTestSet[] = [
2952
2721
*/
2953
2722
describe ( "path-to-regexp" , ( ) => {
2954
2723
describe ( "arguments" , ( ) => {
2955
- it ( "should work without different call combinations" , ( ) => {
2956
- pathToRegexp . pathToRegexp ( "/test" ) ;
2957
- pathToRegexp . pathToRegexp ( "/test" , [ ] ) ;
2958
- pathToRegexp . pathToRegexp ( "/test" , undefined , { } ) ;
2959
-
2960
- pathToRegexp . pathToRegexp ( / ^ \/ t e s t / ) ;
2961
- pathToRegexp . pathToRegexp ( / ^ \/ t e s t / , [ ] ) ;
2962
- pathToRegexp . pathToRegexp ( / ^ \/ t e s t / , undefined , { } ) ;
2963
-
2964
- pathToRegexp . pathToRegexp ( [ "/a" , "/b" ] ) ;
2965
- pathToRegexp . pathToRegexp ( [ "/a" , "/b" ] , [ ] ) ;
2966
- pathToRegexp . pathToRegexp ( [ "/a" , "/b" ] , undefined , { } ) ;
2967
- } ) ;
2968
-
2969
2724
it ( "should accept an array of keys as the second argument" , ( ) => {
2970
- const keys : pathToRegexp . Key [ ] = [ ] ;
2971
- const re = pathToRegexp . pathToRegexp ( "/user/:id" , keys , { end : false } ) ;
2725
+ const re = pathToRegexp . pathToRegexp ( "/user/:id" , { end : false } ) ;
2972
2726
2973
2727
const expectedKeys = [
2974
2728
{
@@ -2980,7 +2734,7 @@ describe("path-to-regexp", () => {
2980
2734
} ,
2981
2735
] ;
2982
2736
2983
- expect ( keys ) . toEqual ( expectedKeys ) ;
2737
+ expect ( re . keys ) . toEqual ( expectedKeys ) ;
2984
2738
expect ( exec ( re , "/user/123/show" ) ) . toEqual ( [ "/user/123" , "123" ] ) ;
2985
2739
} ) ;
2986
2740
@@ -3063,8 +2817,7 @@ describe("path-to-regexp", () => {
3063
2817
"should match $input" ,
3064
2818
testOptions ,
3065
2819
( { input, matches, expected } ) => {
3066
- const keys : pathToRegexp . Key [ ] = [ ] ;
3067
- const re = pathToRegexp . pathToRegexp ( path , keys , options ) ;
2820
+ const re = pathToRegexp . pathToRegexp ( path , options ) ;
3068
2821
const match = pathToRegexp . match ( path , options ) ;
3069
2822
3070
2823
expect ( exec ( re , input ) ) . toEqual ( matches ) ;
0 commit comments