@@ -238,7 +238,10 @@ UrlMatcher.prototype.exec = function (path, searchParams) {
238
238
function decodePathArray ( string ) {
239
239
function reverseString ( str ) { return str . split ( "" ) . reverse ( ) . join ( "" ) ; }
240
240
function unquoteDashes ( str ) { return str . replace ( / \\ - / , "-" ) ; }
241
- return reverseString ( string ) . split ( / - (? ! \\ ) / ) . map ( reverseString ) . map ( unquoteDashes ) . reverse ( ) ;
241
+
242
+ var split = reverseString ( string ) . split ( / - (? ! \\ ) / ) ;
243
+ var allReversed = map ( split , reverseString ) ;
244
+ return map ( allReversed , unquoteDashes ) . reverse ( ) ;
242
245
}
243
246
244
247
for ( i = 0 ; i < nPath ; i ++ ) {
@@ -334,7 +337,7 @@ UrlMatcher.prototype.format = function (values) {
334
337
if ( squash === false ) {
335
338
if ( encoded != null ) {
336
339
if ( isArray ( encoded ) ) {
337
- result += encoded . map ( encodeDashes ) . join ( "-" ) ;
340
+ result += map ( encoded , encodeDashes ) . join ( "-" ) ;
338
341
} else {
339
342
result += encodeURIComponent ( encoded ) ;
340
343
}
@@ -349,7 +352,7 @@ UrlMatcher.prototype.format = function (values) {
349
352
} else {
350
353
if ( encoded == null || ( isDefaultValue && squash !== false ) ) continue ;
351
354
if ( ! isArray ( encoded ) ) encoded = [ encoded ] ;
352
- encoded = encoded . map ( encodeURIComponent ) . join ( '&' + name + '=' ) ;
355
+ encoded = map ( encoded , encodeURIComponent ) . join ( '&' + name + '=' ) ;
353
356
result += ( search ? '&' : '?' ) + ( name + '=' + encoded ) ;
354
357
search = true ;
355
358
}
@@ -498,7 +501,7 @@ Type.prototype.$asArray = function(mode, isSearch) {
498
501
// Wraps type functions to operate on each value of an array
499
502
return function handleArray ( val ) {
500
503
if ( ! isArray ( val ) ) val = [ val ] ;
501
- var result = val . map ( callback ) ;
504
+ var result = map ( val , callback ) ;
502
505
if ( reducefn )
503
506
return result . reduce ( reducefn , true ) ;
504
507
return ( result && result . length == 1 && mode === "auto" ) ? result [ 0 ] : result ;
@@ -844,8 +847,8 @@ function $UrlMatcherFactory() {
844
847
845
848
function getDefaultValueConfig ( config ) {
846
849
var keys = isObject ( config ) ? objectKeys ( config ) : [ ] ;
847
- var isShorthand = keys . indexOf ( "value" ) === - 1 && keys . indexOf ( "type" ) === - 1 &&
848
- keys . indexOf ( "squash" ) === - 1 && keys . indexOf ( "array" ) === - 1 ;
850
+ var isShorthand = indexOf ( keys , "value" ) === - 1 && indexOf ( keys , "type" ) === - 1 &&
851
+ indexOf ( keys , "squash" ) === - 1 && indexOf ( keys , "array" ) === - 1 ;
849
852
var configValue = isShorthand ? config : config . value ;
850
853
return {
851
854
fn : isInjectable ( configValue ) ? configValue : function ( ) { return configValue ; } ,
@@ -886,8 +889,8 @@ function $UrlMatcherFactory() {
886
889
replace = isArray ( config . replace ) ? config . replace : [ ] ;
887
890
if ( isString ( squash ) )
888
891
replace . push ( { from : squash , to : undefined } ) ;
889
- configuredKeys = replace . map ( function ( item ) { return item . from ; } ) ;
890
- return defaultPolicy . filter ( function ( item ) { return configuredKeys . indexOf ( item . from ) === - 1 ; } ) . concat ( replace ) ;
892
+ configuredKeys = map ( replace , function ( item ) { return item . from ; } ) ;
893
+ return filter ( defaultPolicy , function ( item ) { return indexOf ( configuredKeys , item . from ) === - 1 ; } ) . concat ( replace ) ;
891
894
}
892
895
893
896
/**
@@ -905,7 +908,7 @@ function $UrlMatcherFactory() {
905
908
function $value ( value ) {
906
909
function hasReplaceVal ( val ) { return function ( obj ) { return obj . from === val ; } ; }
907
910
function $replace ( value ) {
908
- var replacement = self . replace . filter ( hasReplaceVal ( value ) ) . map ( function ( obj ) { return obj . to ; } ) ;
911
+ var replacement = map ( filter ( self . replace , hasReplaceVal ( value ) ) , function ( obj ) { return obj . to ; } ) ;
909
912
return replacement . length ? replacement [ 0 ] : value ;
910
913
}
911
914
value = $replace ( value ) ;
@@ -943,7 +946,7 @@ function $UrlMatcherFactory() {
943
946
chain . reverse ( ) ;
944
947
forEach ( chain , function ( paramset ) {
945
948
forEach ( objectKeys ( paramset ) , function ( key ) {
946
- if ( keys . indexOf ( key ) === - 1 && ignore . indexOf ( key ) === - 1 ) keys . push ( key ) ;
949
+ if ( indexOf ( keys , key ) === - 1 && indexOf ( ignore , key ) === - 1 ) keys . push ( key ) ;
947
950
} ) ;
948
951
} ) ;
949
952
return keys ;
0 commit comments