Skip to content

Commit 7664cd0

Browse files
committedDec 12, 2017
fix(urlRouter): Update query params when resetting url via .update()
Closes #94
1 parent 8835bc9 commit 7664cd0

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
 

‎src/url/urlRouter.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ export class UrlRouter implements UrlRulesApi, UrlSyncApi, Disposable {
212212
update(read?: boolean) {
213213
let $url = this._router.locationService;
214214
if (read) {
215-
this.location = $url.path();
215+
this.location = $url.url();
216216
return;
217217
}
218-
if ($url.path() === this.location) return;
218+
if ($url.url() === this.location) return;
219219

220220
$url.url(this.location, true);
221221
}

‎test/urlRouterSpec.ts

+14
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,20 @@ describe("UrlRouter", function () {
222222

223223
expect(urlService.path()).toBe('/old');
224224
});
225+
226+
// Test for https://github.com/ui-router/core/issues/94
227+
it('can read and reset URL including query parameters', function () {
228+
urlService.url('/old?param1=hey');
229+
230+
expect(urlService.url()).toBe('/old?param1=hey');
231+
232+
urlRouter.update(true); // save url
233+
urlService.url('/new');
234+
urlRouter.update(); // reset url
235+
236+
expect(urlService.url()).toBe('/old?param1=hey');
237+
});
238+
225239
});
226240

227241
describe("URL generation", function() {

0 commit comments

Comments
 (0)
Please sign in to comment.