File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ PathnameEnvironment.prototype = Object.create(Environment.prototype);
17
17
PathnameEnvironment . prototype . constructor = PathnameEnvironment ;
18
18
19
19
PathnameEnvironment . prototype . getPath = function ( ) {
20
- return window . location . pathname ;
20
+ return window . location . pathname + window . location . search ;
21
21
} ;
22
22
23
23
PathnameEnvironment . prototype . pushState = function ( path , navigation ) {
Original file line number Diff line number Diff line change
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments