-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
Fix URL encoding issue for links #446
Conversation
honestly, now that I look at this, I think the reason I used |
if possible, I'd love to see a "toy" test confirming that |
I will say, tbf, if you pass an already interpolated string to
added a quick test to one of the smaller components 986fd13 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks great, it should solve the issue we were seeing in #437
Fantastic work, thanks for the PR! 🥳
const link = fixture.debugElement.nativeElement.querySelector('a'); | ||
console.log(link); | ||
expect(link.href).toContain( | ||
'/explore/123-456-789%3D/resource/aHR0cHM6Ly93d3cubWVyY3kubmV0L3NpdGVzL2RlZmF1bHQvZmlsZXMvZG9jdG9yX2ltYWdlcy9kZXNrdG9wLzE2NTk4ODYwNTktbS5qcGc%3D' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Description
Fixes #437. Its possible for ids to include non-url-safe characters. Since these ids are being interpolated into a url string without encoding, it is causing the url to fail.
To fix this, I've updated the code so that we are passing urls as arrays of strings rather than an interpolated string. By passing as an array of strings, the built in router knows to encode each string if needed.
There were a few places in components where we were using
navigateByUrl
with an interpolated string.navigateByUrl
doesn't accept an array of strings so I've switched those few places to usenavigate
. I'm not sure if there was a specific reason for usingnavigateByUrl
overnavigate
in those spots. If there is a need to usenavigateByUrl
please let me know and I will update those spots to html-encode another way.Changes
.navigate
instead of.navigateByUrl
to make it easier to ensure proper url encoding