Skip to content

Commit 1ca30af

Browse files
committed
Merge pull request emberjs#3439 from alexspeller/fix-history-location
[FEATURE query-params] Fix history location
2 parents bf0cf32 + 2ad5a22 commit 1ca30af

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

packages/ember-routing/lib/location/history_location.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,16 @@ Ember.HistoryLocation = Ember.Object.extend({
5252
*/
5353
getURL: function() {
5454
var rootURL = get(this, 'rootURL'),
55-
url = get(this, 'location').pathname;
55+
location = get(this, 'location'),
56+
path = location.pathname;
5657

5758
rootURL = rootURL.replace(/\/$/, '');
58-
url = url.replace(rootURL, '');
59+
var url = path.replace(rootURL, '');
60+
61+
if (Ember.FEATURES.isEnabled("query-params")) {
62+
var search = location.search || '';
63+
url += search;
64+
}
5965

6066
return url;
6167
},

packages/ember/tests/routing/query_params_test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,4 +446,21 @@ if (Ember.FEATURES.isEnabled("query-params")) {
446446

447447
equal(editCount, 2, 'set up the edit route twice without failure');
448448
});
449+
450+
test("History location can handle queryparams", function() {
451+
var location = {
452+
pathname: "/foo",
453+
search: "?bar=baz"
454+
};
455+
456+
var history = {
457+
pushState: Ember.K,
458+
replaceState: Ember.K
459+
};
460+
461+
var historyLocation = Ember.HistoryLocation.create({location: location, history: history});
462+
463+
equal(historyLocation.getURL(), "/foo?bar=baz", "The query params are present");
464+
});
465+
449466
}

0 commit comments

Comments
 (0)