X Tutup
Skip to content

fix(router): fixed the location wrapper for angular1#6698

Closed
davidreher wants to merge 1 commit intoangular:masterfrom
BROCKHAUS-AG:router-fix-location-wrapper
Closed

fix(router): fixed the location wrapper for angular1#6698
davidreher wants to merge 1 commit intoangular:masterfrom
BROCKHAUS-AG:router-fix-location-wrapper

Conversation

@davidreher
Copy link
Copy Markdown
Contributor

In angular2 Location.path() returns the complete path including query string. In angular1 the query parameters are missing. Similar to this Location.go does accept two parameters (path and query).

Found and fixed by @Mischi

In angular2 `Location.path()` returns the complete path including query string. In angular1 the query parameters are missing. Similar to this `Location.go` does accept two parameters (path *and query*).
@Mischi
Copy link
Copy Markdown
Contributor

Mischi commented Jan 26, 2016

With this PR merged, query paramters will be reflected in the url as expected (if used within angular1.5).

// Without PR
router.navigateUrl('/something?a=b&c=d'); // results in "/something" in adressbar

// With PR
router.navigateUrl('/something?a=b&c=d'); // results in "/something?a=b&c=d" in adressbar

@davidreher
Copy link
Copy Markdown
Contributor Author

circle failed in npm install ... most likely not because of our change ^^ @btford can you take a look?

@petebacondarwin
Copy link
Copy Markdown
Contributor

LGTM - but we really ought to have tests for all this...

@petebacondarwin petebacondarwin added pr_state: LGTM area: build & ci Related the build and CI infrastructure of the project type: bug/fix and removed area: build & ci Related the build and CI infrastructure of the project labels Jan 29, 2016
Location.prototype.go = function (url) {
return $location.path(url);
Location.prototype.go = function (path, query) {
return $location.url(path + query);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say that this should be

return $location.url(path).search(query);

since simply concatenating would end up with something like

go('a/b/c', 'x=y') -> 'a/b/cx=y'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take that back, it seems that the router passes the & as part of the query!

@petebacondarwin
Copy link
Copy Markdown
Contributor

Closing in favour of #6943, which incorporates this fix and adds tests.

@davidreher davidreher deleted the router-fix-location-wrapper branch February 8, 2016 06:53
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup