Skip to content

Commit

Permalink
[fixed] <Link href> when using HashHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Jun 19, 2015
1 parent ede0b53 commit 178efc3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions modules/HashHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ class HashHistory extends DOMHistory {
this._notifyChange();
}

makeHref(pathname, query) {
return '#' + super.makeHref(pathname, query);
makeHref(path) {
return '#' + path;
}

}
Expand Down
8 changes: 7 additions & 1 deletion modules/RouterContextMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ var RouterContextMixin = {
* pathname and query.
*/
makeHref(pathname, query) {
return this.makePath(pathname, query);
var path = this.makePath(pathname, query);
var { history } = this.props;

if (history && history.makeHref)
return history.makeHref(path);

return path;
},

/**
Expand Down
4 changes: 2 additions & 2 deletions modules/__tests__/Link-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ describe('A <Link>', function () {
});

render((
<Router history={new HashHistory()}>
<Router history={new HashHistory}>
<Route path="/" component={LinkWrapper}/>
</Router>
), div, function () {
var a = div.querySelector('a');
expect(a.getAttribute('href')).toEqual('/#/hello/michael?the=query');
expect(a.getAttribute('href')).toEqual('#/hello/michael?the=query');
});
});

Expand Down

0 comments on commit 178efc3

Please sign in to comment.