@@ -813,6 +813,47 @@ describe('$route', function() {
813
813
} ) ;
814
814
815
815
816
+ it ( 'should interpolate optional route vars in the redirected path from original path' , function ( ) {
817
+ module ( function ( $routeProvider ) {
818
+ $routeProvider . when ( '/foo/:id/foo/:subid?/:extraId' , { redirectTo : '/bar/:id/:subid?/23' } ) ;
819
+ $routeProvider . when ( '/bar/:id/:subid?/:subsubid' , { templateUrl : 'bar.html' } ) ;
820
+ } ) ;
821
+
822
+ inject ( function ( $route , $location , $rootScope ) {
823
+ $location . path ( '/foo/id1/foo/subid3/gah' ) ;
824
+ $rootScope . $digest ( ) ;
825
+
826
+ expect ( $location . path ( ) ) . toEqual ( '/bar/id1/subid3/23' ) ;
827
+ expect ( $location . search ( ) ) . toEqual ( { extraId : 'gah' } ) ;
828
+ expect ( $route . current . params ) . toEqual ( { id :'id1' , subid :'subid3' , subsubid :'23' , extraId :'gah' } ) ;
829
+ expect ( $route . current . templateUrl ) . toEqual ( 'bar.html' ) ;
830
+
831
+ $location . path ( '/foo/id1/foo/gah' ) ;
832
+ $rootScope . $digest ( ) ;
833
+
834
+ expect ( $location . path ( ) ) . toEqual ( '/bar/id1/23' ) ;
835
+ expect ( $location . search ( ) ) . toEqual ( { extraId : 'gah' } ) ;
836
+ expect ( $route . current . params ) . toEqual ( { id :'id1' , subsubid :'23' , extraId :'gah' } ) ;
837
+ } ) ;
838
+ } ) ;
839
+
840
+
841
+ it ( 'should interpolate catch-all route vars in the redirected path from original path' , function ( ) {
842
+ module ( function ( $routeProvider ) {
843
+ $routeProvider . when ( '/baz/:id/:path*' , { redirectTo : '/path/:path*/:id' } ) ;
844
+ $routeProvider . when ( '/path/:path*/:id' , { templateUrl : 'foo.html' } ) ;
845
+ } ) ;
846
+
847
+ inject ( function ( $route , $location , $rootScope ) {
848
+ $location . path ( '/baz/1/foovalue/barvalue' ) ;
849
+ $rootScope . $digest ( ) ;
850
+ expect ( $location . path ( ) ) . toEqual ( '/path/foovalue/barvalue/1' ) ;
851
+ expect ( $route . current . params ) . toEqual ( { id :'1' , path :'foovalue/barvalue' } ) ;
852
+ expect ( $route . current . templateUrl ) . toEqual ( 'foo.html' ) ;
853
+ } ) ;
854
+ } ) ;
855
+
856
+
816
857
it ( 'should interpolate route vars in the redirected path from original search' , function ( ) {
817
858
module ( function ( $routeProvider ) {
818
859
$routeProvider . when ( '/bar/:id/:subid/:subsubid' , { templateUrl : 'bar.html' } ) ;
0 commit comments