@@ -501,14 +501,15 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $
501501 */
502502 // $urlRouter is injected just to ensure it gets instantiated
503503 this . $get = $get ;
504- $get . $inject = [ '$rootScope' , '$q' , '$view' , '$injector' , '$resolve' , '$stateParams' , '$location' , '$urlRouter' ] ;
505- function $get ( $rootScope , $q , $view , $injector , $resolve , $stateParams , $location , $urlRouter ) {
504+ $get . $inject = [ '$rootScope' , '$q' , '$view' , '$injector' , '$resolve' , '$stateParams' , '$location' , '$urlRouter' , '$browser' ] ;
505+ function $get ( $rootScope , $q , $view , $injector , $resolve , $stateParams , $location , $urlRouter , $browser ) {
506506
507507 var TransitionSuperseded = $q . reject ( new Error ( 'transition superseded' ) ) ;
508508 var TransitionPrevented = $q . reject ( new Error ( 'transition prevented' ) ) ;
509509 var TransitionAborted = $q . reject ( new Error ( 'transition aborted' ) ) ;
510510 var TransitionFailed = $q . reject ( new Error ( 'transition failed' ) ) ;
511511 var currentLocation = $location . url ( ) ;
512+ var baseHref = $browser . baseHref ( ) ;
512513
513514 function syncUrl ( ) {
514515 if ( $location . url ( ) !== currentLocation ) {
@@ -1038,6 +1039,15 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $
10381039 if ( ! $locationProvider . html5Mode ( ) && url ) {
10391040 url = "#" + $locationProvider . hashPrefix ( ) + url ;
10401041 }
1042+
1043+ if ( baseHref !== '/' ) {
1044+ if ( $locationProvider . html5Mode ( ) ) {
1045+ url = baseHref . slice ( 0 , - 1 ) + url ;
1046+ } else if ( options . absolute ) {
1047+ url = baseHref . slice ( 1 ) + url ;
1048+ }
1049+ }
1050+
10411051 if ( options . absolute && url ) {
10421052 url = $location . protocol ( ) + '://' +
10431053 $location . host ( ) +
0 commit comments