Skip to content

Commit ce5c0f7

Browse files
committed
Make .href() support .hashPrefix()
1 parent bc9cb5f commit ce5c0f7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/state.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $
475475
var nav = (state && options.lossy) ? state.navigable : state;
476476
var url = (nav && nav.url) ? nav.url.format(normalize(state.params, params || {})) : null;
477477
if (!$locationProvider.html5Mode() && url) {
478-
url = "#" + url;
478+
url = "#" + $locationProvider.hashPrefix() + url;
479479
}
480480
if (options.absolute && url) {
481481
url = $location.protocol() + '://' +

test/stateSpec.js

+5
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,11 @@ describe('state', function () {
613613
locationProvider.html5Mode(true);
614614
expect($state.href("about.sidebar", null, { absolute: true })).toEqual("http://server/about");
615615
}));
616+
617+
it('respects $locationProvider.hashPrefix()', inject(function ($state) {
618+
locationProvider.hashPrefix("!");
619+
expect($state.href("home")).toEqual("#!/");
620+
}));
616621
});
617622

618623
describe('.get()', function () {

0 commit comments

Comments
 (0)