@@ -38,10 +38,10 @@ describe('isRedirectURL', () => {
3838 } ) ;
3939 it ( `Match redirect pattern with regex: partial match` , ( ) => {
4040 const url = 'http://www.example.com/' ;
41- const conf = config ( [ [ 'http://www\.example\.com/ ' , 'firefox' ] ] , [ ] , { UseRegex : 1 } )
41+ const conf = config ( [ [ 'http://www\.example\..* ' , 'firefox' ] ] , [ ] , { UseRegex : 1 } )
4242 assert . equal ( redirector . isRedirectURL ( conf , url ) , true ) ;
4343 } ) ;
44- it ( `Match redirect pattern with regex: exact match ` , ( ) => {
44+ it ( `Match redirect pattern with regex: extra caret and dollar ` , ( ) => {
4545 const url = 'http://www.example.com/' ;
4646 const conf = config ( [ [ '^http://www\.example\.com/$' , 'firefox' ] ] , [ ] , { UseRegex : 1 } )
4747 assert . equal ( redirector . isRedirectURL ( conf , url ) , true ) ;
@@ -114,6 +114,11 @@ describe('isRedirectURL', () => {
114114 const conf = config ( [ [ 'http://www\.example\.com/' , 'firefox' ] ] , [ ] , { UseRegex : 1 } )
115115 assert . equal ( redirector . isRedirectURL ( conf , url ) , false ) ;
116116 } ) ;
117+ it ( `Unmatch redirect pattern with regex: not exact match` , ( ) => {
118+ const url = 'http://www.example.com/' ;
119+ const conf = config ( [ [ '\.example\.' , 'firefox' ] ] , [ ] , { UseRegex : 1 } )
120+ assert . equal ( redirector . isRedirectURL ( conf , url ) , false ) ;
121+ } ) ;
117122 } ) ;
118123 describe ( 'HostName patterns' , ( ) => {
119124 it ( `Match redirect pattern without wildcard` , ( ) => {
@@ -126,16 +131,21 @@ describe('isRedirectURL', () => {
126131 const conf = config ( [ ] , [ [ '*.example.com' , 'firefox' ] ] )
127132 assert . equal ( redirector . isRedirectURL ( conf , url ) , true ) ;
128133 } ) ;
129- it ( `Match redirect pattern with regex: partial match ` , ( ) => {
134+ it ( `Match redirect pattern with regex` , ( ) => {
130135 const url = 'http://www.example.com/' ;
131136 const conf = config ( [ ] , [ [ 'www\.example\.com' , 'firefox' ] ] , { UseRegex : 1 } )
132137 assert . equal ( redirector . isRedirectURL ( conf , url ) , true ) ;
133138 } ) ;
134- it ( `Match redirect pattern with regex: exact match ` , ( ) => {
139+ it ( `Match redirect pattern with regex: extra caret and dollar ` , ( ) => {
135140 const url = 'http://www.example.com/' ;
136141 const conf = config ( [ ] , [ [ '^www\.example\.com$' , 'firefox' ] ] , { UseRegex : 1 } )
137142 assert . equal ( redirector . isRedirectURL ( conf , url ) , true ) ;
138143 } ) ;
144+ it ( `Match redirect pattern with regex: partial match` , ( ) => {
145+ const url = 'http://www.example.com/' ;
146+ const conf = config ( [ ] , [ [ '.*\.example\..*' , 'firefox' ] ] , { UseRegex : 1 } )
147+ assert . equal ( redirector . isRedirectURL ( conf , url ) , true ) ;
148+ } ) ;
139149 it ( `Match first pattern: redirection (matches firefox)` , ( ) => {
140150 const url = 'http://www.example.com/' ;
141151 const conf = config (
@@ -215,6 +225,11 @@ describe('isRedirectURL', () => {
215225 const conf = config ( [ ] , [ [ 'http://www.example.com' , 'firefox' ] ] , { UseRegex : 1 } )
216226 assert . equal ( redirector . isRedirectURL ( conf , url ) , false ) ;
217227 } ) ;
228+ it ( `Unmatch redirect pattern with regex: not exact match` , ( ) => {
229+ const url = 'http://www.example.com/' ;
230+ const conf = config ( [ ] , [ [ '\.example\.' , 'firefox' ] ] , { UseRegex : 1 } )
231+ assert . equal ( redirector . isRedirectURL ( conf , url ) , false ) ;
232+ } ) ;
218233 } ) ;
219234 } ) ;
220235 } ) ;
0 commit comments