@@ -864,27 +864,23 @@ function $UrlMatcherFactory() {
864
864
865
865
this . Param = function Param ( id , type , config , location ) {
866
866
var self = this ;
867
- var defaultValueConfig = getDefaultValueConfig ( config ) ;
868
- config = config || { } ;
867
+ config = unwrapShorthand ( config ) ;
869
868
type = getType ( config , type ) ;
870
869
var arrayMode = getArrayMode ( ) ;
871
870
type = arrayMode ? type . $asArray ( arrayMode , location === "search" ) : type ;
872
- if ( type . name === "string" && ! arrayMode && location === "path" && defaultValueConfig . value === undefined )
873
- defaultValueConfig . value = "" ; // for 0.2.x; in 0.3.0+ do not automatically default to ""
874
- var isOptional = defaultValueConfig . value !== undefined ;
871
+ if ( type . name === "string" && ! arrayMode && location === "path" && config . value === undefined )
872
+ config . value = "" ; // for 0.2.x; in 0.3.0+ do not automatically default to ""
873
+ var isOptional = config . value !== undefined ;
875
874
var squash = getSquashPolicy ( config , isOptional ) ;
876
875
var replace = getReplace ( config , arrayMode , isOptional , squash ) ;
877
876
878
- function getDefaultValueConfig ( config ) {
877
+ function unwrapShorthand ( config ) {
879
878
var keys = isObject ( config ) ? objectKeys ( config ) : [ ] ;
880
879
var isShorthand = indexOf ( keys , "value" ) === - 1 && indexOf ( keys , "type" ) === - 1 &&
881
880
indexOf ( keys , "squash" ) === - 1 && indexOf ( keys , "array" ) === - 1 ;
882
- var configValue = isShorthand ? config : config . value ;
883
- var result = {
884
- fn : isInjectable ( configValue ) ? configValue : function ( ) { return result . value ; } ,
885
- value : configValue
886
- } ;
887
- return result ;
881
+ if ( isShorthand ) config = { value : config } ;
882
+ config . $$fn = isInjectable ( config . value ) ? config . value : function ( ) { return config . value ; } ;
883
+ return config ;
888
884
}
889
885
890
886
function getType ( config , urlType ) {
@@ -929,7 +925,7 @@ function $UrlMatcherFactory() {
929
925
*/
930
926
function $$getDefaultValue ( ) {
931
927
if ( ! injector ) throw new Error ( "Injectable functions cannot be called at configuration time" ) ;
932
- return injector . invoke ( defaultValueConfig . fn ) ;
928
+ return injector . invoke ( config . $$ fn) ;
933
929
}
934
930
935
931
/**
0 commit comments