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

Refresh error due to double encoding in verticalUrl #836

Merged
merged 3 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions layouts/html.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@
{{#babel}}
function iframeGetSearchParams() {
let params = new URLSearchParams(window.location.search);
let verticalUrl = window.location.pathname.substr(1)
if (verticalUrl) {
params.set('verticalUrl', verticalUrl);
}
return params.toString();
let verticalUrl = window.location.pathname.substr(1);
yen-tt marked this conversation as resolved.
Show resolved Hide resolved
yen-tt marked this conversation as resolved.
Show resolved Hide resolved
return verticalUrl
? params.toString() + '&verticalUrl=' + verticalUrl
: params.toString();
}
let iframeLoadedResolve;
window.iframeLoaded = new Promise(resolve => {
Expand Down
2 changes: 1 addition & 1 deletion static/js/iframe-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function generateIFrame(domain, queryParam, urlParam) {
paramString = paramString.substr(1, paramString.length);

// Decode ASCII forward slash to avod repeat encodings on page refreshes
paramString = paramString.replace("%2F", "/");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we able to get rid of this because window.location.search is already encoded?

Copy link
Contributor Author

@yen-tt yen-tt Jun 16, 2021

Choose a reason for hiding this comment

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

yeah, it's already encoded pulling from browser. I believe this was added before to avoid the same double encoding problem with multilang when the verticalUrl is something like 'es/help_articles' but this change should fix this!

paramString = paramString.replaceAll("%2F", "/");

// Parse the params out of the URL
var params = paramString.split('&'),
Expand Down