@@ -238,7 +238,10 @@ UrlMatcher.prototype.exec = function (path, searchParams) {
238238 function decodePathArray ( string ) {
239239 function reverseString ( str ) { return str . split ( "" ) . reverse ( ) . join ( "" ) ; }
240240 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 ( ) ;
242245 }
243246
244247 for ( i = 0 ; i < nPath ; i ++ ) {
@@ -334,7 +337,7 @@ UrlMatcher.prototype.format = function (values) {
334337 if ( squash === false ) {
335338 if ( encoded != null ) {
336339 if ( isArray ( encoded ) ) {
337- result += encoded . map ( encodeDashes ) . join ( "-" ) ;
340+ result += map ( encoded , encodeDashes ) . join ( "-" ) ;
338341 } else {
339342 result += encodeURIComponent ( encoded ) ;
340343 }
@@ -349,7 +352,7 @@ UrlMatcher.prototype.format = function (values) {
349352 } else {
350353 if ( encoded == null || ( isDefaultValue && squash !== false ) ) continue ;
351354 if ( ! isArray ( encoded ) ) encoded = [ encoded ] ;
352- encoded = encoded . map ( encodeURIComponent ) . join ( '&' + name + '=' ) ;
355+ encoded = map ( encoded , encodeURIComponent ) . join ( '&' + name + '=' ) ;
353356 result += ( search ? '&' : '?' ) + ( name + '=' + encoded ) ;
354357 search = true ;
355358 }
@@ -498,7 +501,7 @@ Type.prototype.$asArray = function(mode, isSearch) {
498501 // Wraps type functions to operate on each value of an array
499502 return function handleArray ( val ) {
500503 if ( ! isArray ( val ) ) val = [ val ] ;
501- var result = val . map ( callback ) ;
504+ var result = map ( val , callback ) ;
502505 if ( reducefn )
503506 return result . reduce ( reducefn , true ) ;
504507 return ( result && result . length == 1 && mode === "auto" ) ? result [ 0 ] : result ;
@@ -844,8 +847,8 @@ function $UrlMatcherFactory() {
844847
845848 function getDefaultValueConfig ( config ) {
846849 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 ;
849852 var configValue = isShorthand ? config : config . value ;
850853 return {
851854 fn : isInjectable ( configValue ) ? configValue : function ( ) { return configValue ; } ,
@@ -886,8 +889,8 @@ function $UrlMatcherFactory() {
886889 replace = isArray ( config . replace ) ? config . replace : [ ] ;
887890 if ( isString ( squash ) )
888891 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 ) ;
891894 }
892895
893896 /**
@@ -905,7 +908,7 @@ function $UrlMatcherFactory() {
905908 function $value ( value ) {
906909 function hasReplaceVal ( val ) { return function ( obj ) { return obj . from === val ; } ; }
907910 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 ; } ) ;
909912 return replacement . length ? replacement [ 0 ] : value ;
910913 }
911914 value = $replace ( value ) ;
@@ -943,7 +946,7 @@ function $UrlMatcherFactory() {
943946 chain . reverse ( ) ;
944947 forEach ( chain , function ( paramset ) {
945948 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 ) ;
947950 } ) ;
948951 } ) ;
949952 return keys ;
0 commit comments