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

fixes #15363 - construct correct templates query for new hosts #3586

Closed
wants to merge 1 commit into from

Conversation

domcleal
Copy link
Contributor

No description provided.

@@ -255,7 +255,7 @@ function template_info(div, url) {
// Use a post to avoid request URI too large issues with big forms
$.ajax({
type: "POST",
url: url + "&provisioning=" + build,
url: url + ((url.indexOf('?') == -1) ? '?' : '&') + "provisioning=" + build,
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: isnt it enough to find the first usage of ? vs anywhere in the string? for example:

(new URL(url)).search[0] === '?'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't tell what advantage that provides over the current implementation. Are you suggesting it needs to handle question marks in the path or host portions of the URL?

Copy link
Member

Choose a reason for hiding this comment

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

again - nitpick, however, i believe this is more "correct" e.g. your code will return true if url has a question mark in the middle of the string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

url.indexOf('?') should return false if there's a question mark in the url string, as that would be interpreted as a query string by the server. If the path component of the URL was intended to contain a question mark, it would be URL-encoded and not picked up by indexOf.

Copy link
Member

Choose a reason for hiding this comment

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

my point is that since this bug is in contruction the url, we can be a bit more specific. for example:

url="http://localhost:3000/hosts/template_used?x=1?&=2"
url.indexOf('?')
41
url="http://localhost:3000/hosts/template_used&x=1?y=2"
url.indexOf('?')
45

I realize that my solution is not useful either in this case:
when testing with URL

"http://localhost:3000/hosts/template_used&x=1?y=2"
(new URL(url)).search
"?y=2"

I guess this not worth the time, merging :)

@ohadlevy
Copy link
Member

merged as 8e2a541 thanks @domcleal

@ohadlevy ohadlevy closed this Jun 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants