diff --git a/src/urlRouter.js b/src/urlRouter.js index 5bdb58ff8..4e5fbc4a2 100644 --- a/src/urlRouter.js +++ b/src/urlRouter.js @@ -381,6 +381,10 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) { if (!urlMatcher.validates(params)) return null; var isHtml5 = $locationProvider.html5Mode(); + if (angular.isObject(isHtml5)) { + isHtml5 = isHtml5.enabled; + } + var url = urlMatcher.format(params); options = options || {}; diff --git a/test/urlRouterSpec.js b/test/urlRouterSpec.js index 8cc41698f..f0235ecb2 100644 --- a/test/urlRouterSpec.js +++ b/test/urlRouterSpec.js @@ -1,6 +1,6 @@ describe("UrlRouter", function () { - var $urp, $ur, location, match, scope; + var $urp, $lp, $ur, location, match, scope; describe("provider", function () { @@ -46,8 +46,9 @@ describe("UrlRouter", function () { describe("service", function() { beforeEach(function() { - angular.module('ui.router.router.test', function() {}).config(function ($urlRouterProvider) { + angular.module('ui.router.router.test', function() {}).config(function ($urlRouterProvider, $locationProvider) { $urp = $urlRouterProvider; + $lp = $locationProvider; $urp.rule(function ($injector, $location) { var path = $location.path(); @@ -198,6 +199,15 @@ describe("UrlRouter", function () { expect($urlRouter.href(matcher, { param: 1138 })).toBe('#/foo/1138'); expect($urlRouter.href(matcher, { param: 5 })).toBeNull(); })); + + it('should handle the new html5Mode object config from Angular 1.3', inject(function($urlRouter) { + + $lp.html5Mode({ + enabled: false + }); + + expect($urlRouter.href(new UrlMatcher('/hello'))).toBe('#/hello'); + })); }); });