@@ -47,22 +47,26 @@ const init = (FlowRouter) => {
47
47
disabledClass : 'disabled'
48
48
} ) ;
49
49
50
- const test = ( value , pattern ) => {
51
- let result ;
50
+ const test = ( _value , _pattern ) => {
51
+ let value = _value ;
52
+ let pattern = _pattern ;
52
53
if ( ! value ) {
53
54
return false ;
54
55
}
56
+
55
57
if ( Match . test ( pattern , RegExp ) ) {
56
- result = value . search ( pattern ) ;
57
- result = result > - 1 ;
58
- } else if ( Match . test ( pattern , String ) ) {
58
+ return value . search ( pattern ) > - 1 ;
59
+ }
60
+
61
+ if ( Match . test ( pattern , String ) ) {
59
62
if ( config . equals ( 'caseSensitive' , false ) ) {
60
63
value = value . toLowerCase ( ) ;
61
64
pattern = pattern . toLowerCase ( ) ;
62
65
}
63
- result = ( value === pattern ) ;
66
+ return ( value === pattern ) ;
64
67
}
65
- return ( result != null ) ? result : false ;
68
+
69
+ return false ;
66
70
} ;
67
71
68
72
const ActiveRoute = {
@@ -114,9 +118,9 @@ const init = (FlowRouter) => {
114
118
}
115
119
helperName += 'Active' + type ;
116
120
117
- return ( options = { } , attributes = { } ) => {
118
- options = ( _ . isObject ( options ) ) ? ( options . hash || options ) : options ;
119
- attributes = ( _ . isObject ( attributes ) ) ? ( attributes . hash || attributes ) : attributes ;
121
+ return ( _options = { } , _attributes = { } ) => {
122
+ let options = ( _ . isObject ( _options ) ) ? ( _options . hash || _options ) : _options ;
123
+ let attributes = ( _ . isObject ( _attributes ) ) ? ( _attributes . hash || _attributes ) : _attributes ;
120
124
121
125
if ( Match . test ( options , String ) ) {
122
126
if ( config . equals ( 'regex' , true ) ) {
@@ -167,16 +171,16 @@ const init = (FlowRouter) => {
167
171
}
168
172
}
169
173
170
- if ( regex == null ) {
174
+ if ( ! _ . isRegExp ( regex ) ) {
171
175
regex = name || path ;
172
176
}
173
177
174
178
if ( inverse ) {
175
- if ( className == null ) {
179
+ if ( ! _ . isString ( className ) ) {
176
180
className = config . get ( 'disabledClass' ) ;
177
181
}
178
182
} else {
179
- if ( className == null ) {
183
+ if ( ! _ . isString ( className ) ) {
180
184
className = config . get ( 'activeClass' ) ;
181
185
}
182
186
}
@@ -220,8 +224,8 @@ const init = (FlowRouter) => {
220
224
// arillo:flow-router-helpers
221
225
// https://github.com/arillo/meteor-flow-router-helpers
222
226
// License (MIT License): https://github.com/arillo/meteor-flow-router-helpers/blob/master/LICENCE
223
- const subsReady = ( ...subs ) => {
224
- subs = subs . slice ( 0 , - 1 ) ;
227
+ const subsReady = ( ..._subs ) => {
228
+ let subs = _subs . slice ( 0 , - 1 ) ;
225
229
if ( subs . length === 1 ) {
226
230
return FlowRouter . subsReady ( ) ;
227
231
}
@@ -233,7 +237,9 @@ const init = (FlowRouter) => {
233
237
} , true ) ;
234
238
} ;
235
239
236
- const pathFor = ( path , view = { hash : { } } ) => {
240
+ const pathFor = ( _path , _view = { hash : { } } ) => {
241
+ let path = _path ;
242
+ let view = _view ;
237
243
if ( ! path ) {
238
244
throw new Error ( 'no path defined' ) ;
239
245
}
@@ -244,12 +250,12 @@ const init = (FlowRouter) => {
244
250
} ;
245
251
}
246
252
247
- if ( path . hash && path . hash . route != null ) {
253
+ if ( path . hash && path . hash . route ) {
248
254
view = path ;
249
255
path = view . hash . route ;
250
256
delete view . hash . route ;
251
257
}
252
- const query = view . hash . query ? FlowRouter . _qs . parse ( view . hash . query ) : { } ;
258
+ const query = view . hash . query ? FlowRouter . _qs . parse ( view . hash . query ) : { } ;
253
259
const hashBang = view . hash . hash ? view . hash . hash : '' ;
254
260
return FlowRouter . path ( path , view . hash , query ) + ( hashBang ? '#' + hashBang : '' ) ;
255
261
} ;
@@ -305,7 +311,7 @@ const init = (FlowRouter) => {
305
311
}
306
312
}
307
313
308
- return _ . extend ( ActiveRoute , FlowRouterHelpers ) ;
314
+ return Object . assign ( { } , ActiveRoute , FlowRouterHelpers ) ;
309
315
} ;
310
316
311
317
export default init ;
0 commit comments