@@ -79,6 +79,14 @@ describe("UrlMatch-search", () => {
7979 expect ( url . match ( "https://example.com/foo/bar/example.path" ) ) . toEqual ( [ "ok1" ] ) ;
8080 expect ( url . match ( "https://example.com/foo/bar/example.path2" ) ) . toEqual ( [ "ok1" ] ) ;
8181 } ) ;
82+ it ( "*.example.com/path/*" , ( ) => {
83+ const url = new UrlMatch < string > ( ) ;
84+ url . add ( "*.example.com/path/*" , "ok1" ) ;
85+ expect ( url . match ( "https://www.example.com/path/foo" ) ) . toEqual ( [ "ok1" ] ) ;
86+ expect ( url . match ( "https://www.example.com/path/foo/bar" ) ) . toEqual ( [ "ok1" ] ) ;
87+ expect ( url . match ( "https://www.example.com/path/foo/bar/baz" ) ) . toEqual ( [ "ok1" ] ) ;
88+ expect ( url . match ( "https://www.example.com/path2/foo" ) ) . toEqual ( [ ] ) ;
89+ } ) ;
8290} ) ;
8391
8492describe ( "UrlMatch-port1" , ( ) => {
@@ -137,18 +145,21 @@ describe("dealPatternMatches", () => {
137145 "*://api.*.example.com/*" ,
138146 "*://api.*.*.example.com/*" ,
139147 "*://*example.com/*" ,
148+ "*.example.com/path/*" ,
140149 ] ) ;
141150 expect ( matches . patternResult ) . toEqual ( [
142151 "*://*/*" ,
143152 "*://*.example.com/*" ,
144153 "*://*.example.com/*" ,
145154 "*://example.com/*" ,
155+ "*://*.example.com/path/*" ,
146156 ] ) ;
147157 expect ( matches . result ) . toEqual ( [
148158 "*://www.example.com*" ,
149159 "*://api.*.example.com/*" ,
150160 "*://api.*.*.example.com/*" ,
151161 "*://*example.com/*" ,
162+ "*.example.com/path/*" ,
152163 ] ) ;
153164 } ) ;
154165 it ( "特殊情况-exclude" , ( ) => {
@@ -239,5 +250,12 @@ describe("parsePatternMatchesURL", () => {
239250 host : "*.example.com" ,
240251 path : "*" ,
241252 } ) ;
253+ matches = parsePatternMatchesURL ( "*.example.com/path/*" ) ;
254+ console . log ( matches ) ;
255+ expect ( matches ) . toEqual ( {
256+ scheme : "*" ,
257+ host : "*.example.com" ,
258+ path : "path/*" ,
259+ } ) ;
242260 } ) ;
243261} ) ;
0 commit comments