Skip to content

Commit 744d760

Browse files
committed
Fix #160
1 parent eeda11d commit 744d760

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

lib/environment/PathnameEnvironment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ PathnameEnvironment.prototype = Object.create(Environment.prototype);
1717
PathnameEnvironment.prototype.constructor = PathnameEnvironment;
1818

1919
PathnameEnvironment.prototype.getPath = function() {
20-
return window.location.pathname;
20+
return window.location.pathname + window.location.search;
2121
};
2222

2323
PathnameEnvironment.prototype.pushState = function(path, navigation) {

tests/browser/PathnameEnvironment.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"use strict";
2+
3+
var assert = require('assert');
4+
var PathnameEnvironment = require('../../lib/environment/PathnameEnvironment');
5+
6+
describe('PathnameEnvironment', function() {
7+
8+
var env, origPath;
9+
10+
beforeEach(function() {
11+
env = new PathnameEnvironment();
12+
origPath = window.location.pathname;
13+
});
14+
15+
afterEach(function() {
16+
window.history.pushState({}, '', origPath);
17+
});
18+
19+
it('updates the url bar on setPath', function() {
20+
env.setPath('/foo/bar/baz?key=x', {});
21+
assert.equal(window.location.pathname, '/foo/bar/baz');
22+
assert.equal(window.location.search, '?key=x');
23+
});
24+
25+
it('returns the full url via getPath', function() {
26+
assert.equal(env.getPath(), origPath);
27+
window.history.pushState({}, '', '/foo/bar/biff?key=y');
28+
assert.equal(env.getPath(), '/foo/bar/biff?key=y');
29+
});
30+
31+
});

0 commit comments

Comments
 (0)