@@ -501,14 +501,15 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $
501
501
*/
502
502
// $urlRouter is injected just to ensure it gets instantiated
503
503
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 ) {
506
506
507
507
var TransitionSuperseded = $q . reject ( new Error ( 'transition superseded' ) ) ;
508
508
var TransitionPrevented = $q . reject ( new Error ( 'transition prevented' ) ) ;
509
509
var TransitionAborted = $q . reject ( new Error ( 'transition aborted' ) ) ;
510
510
var TransitionFailed = $q . reject ( new Error ( 'transition failed' ) ) ;
511
511
var currentLocation = $location . url ( ) ;
512
+ var baseHref = $browser . baseHref ( ) ;
512
513
513
514
function syncUrl ( ) {
514
515
if ( $location . url ( ) !== currentLocation ) {
@@ -1038,6 +1039,15 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $
1038
1039
if ( ! $locationProvider . html5Mode ( ) && url ) {
1039
1040
url = "#" + $locationProvider . hashPrefix ( ) + url ;
1040
1041
}
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
+
1041
1051
if ( options . absolute && url ) {
1042
1052
url = $location . protocol ( ) + '://' +
1043
1053
$location . host ( ) +
0 commit comments