From ce5c0f73c008ca092eb9782865f35e90183c66f1 Mon Sep 17 00:00:00 2001 From: Chris Esplin Date: Wed, 6 Nov 2013 14:27:32 -0700 Subject: [PATCH] Make .href() support .hashPrefix() --- src/state.js | 2 +- test/stateSpec.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/state.js b/src/state.js index 3d8db8b65..cd55fa80a 100644 --- a/src/state.js +++ b/src/state.js @@ -475,7 +475,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $ var nav = (state && options.lossy) ? state.navigable : state; var url = (nav && nav.url) ? nav.url.format(normalize(state.params, params || {})) : null; if (!$locationProvider.html5Mode() && url) { - url = "#" + url; + url = "#" + $locationProvider.hashPrefix() + url; } if (options.absolute && url) { url = $location.protocol() + '://' + diff --git a/test/stateSpec.js b/test/stateSpec.js index e7f48433d..deac94f79 100644 --- a/test/stateSpec.js +++ b/test/stateSpec.js @@ -613,6 +613,11 @@ describe('state', function () { locationProvider.html5Mode(true); expect($state.href("about.sidebar", null, { absolute: true })).toEqual("http://server/about"); })); + + it('respects $locationProvider.hashPrefix()', inject(function ($state) { + locationProvider.hashPrefix("!"); + expect($state.href("home")).toEqual("#!/"); + })); }); describe('.get()', function () {