Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Alpha 44][Router] Parenthesis in urls #4895

Closed
ocombe opened this issue Oct 25, 2015 · 10 comments
Closed

[Alpha 44][Router] Parenthesis in urls #4895

ocombe opened this issue Oct 25, 2015 · 10 comments

Comments

@ocombe
Copy link
Contributor

ocombe commented Oct 25, 2015

I have a problem with parenthesis characters:
this.router.navigate(['./Show', {id: "The Player (2015)"]);
---> works on first try
---> doesn't work on page refresh returns "The Player " (instead of "The Player (2015)")

And when I try to URI encode them:
this.router.navigate(['./Show', {id: encodeURIComponent("The Player (2015)")]);
---> doesn't works on first try (route params return "The%20Player%20")
---> doesn't work on page refresh returns "The%20Player%20" (instead of "The%20Player%20(2015)")

I guess that the problem is that the router will think that those parenthesis are auxiliary routes when you refresh the app. The router should probably encode those to something else and decode them for the params.
I'll make that myself for now, but it would probably be a good idea to have this implemented within the router himself for all "special" characters that it might use. I shouldn't be limited in any way regarding the characters that I put into the url.

@Krustie101
Copy link

@ocombe FYI: encodeURIComponent does not encode ( or ). Are you sure that you get "The%20Player%20" in your RouteParams on your first try after encoding? I do not see that behaviour, I get "The%20Player%20(2015)" as expected.

@ocombe
Copy link
Contributor Author

ocombe commented Oct 25, 2015

Yes I know that it doesn't encode parenthesis, but I tried it before discovering auxiliary routes, which seems to be the problem here. Because it works until I refresh the page and then the router gets fooled when analyzing the url :-/

@ocombe
Copy link
Contributor Author

ocombe commented Oct 25, 2015

OK I temporary fixed this problem by running all my routes through an extended encodeURIComponent function:

encodeURIComponent(str) {
    return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
        return '%' + c.charCodeAt(0).toString(16);
    });
}

Still it would be nice to have this built into the router.
/poke @btford

@kamarouski
Copy link

I have the same issue with Component router in Angular 2 RC1

@felipedrumond
Copy link

HI ocombe. Did you find a solution for parenthesis on url parameters? This issue still exists in RC4!

@ocombe
Copy link
Contributor Author

ocombe commented Jul 25, 2016

I haven't retried since then

@vicb
Copy link
Contributor

vicb commented Jul 26, 2016

Could you please open a new issue if the bug still exists. The router is brand new.

@vicb vicb closed this as completed Jul 26, 2016
@ericmartinezr
Copy link
Contributor

@vicb in that case the other one (#10280) should be reopened

@felipedrumond
Copy link

Any updates or workaround for this issue guys?

@angular-automatic-lock-bot
Copy link

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 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants