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

Only prepend http:// if it wasn't provided #513

Conversation

ttilberg
Copy link
Contributor

@ttilberg ttilberg commented Dec 8, 2017

This is a possible solution for issue #512 where Mechanize is forcing http:// into the string, even if it was provided.

I don't know how far back in ruby versions things like =~ and %r(regex) go, so if these need to be changed to get better backwards compat, I'm all ears!

@@ -1234,7 +1234,7 @@ def set_proxy addr, port, user = nil, pass = nil
end
end

proxy_uri = URI "http://#{addr}"
proxy_uri = URI (addr =~ %r(^https?://) ? addr : "http://#{addr}")
Copy link
Member

Choose a reason for hiding this comment

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

Can you make this two lines?

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've updated the commit to split the string manipulation from the URI parsing. Please let me know if there's anything else, as I'm relatively fresh to this.

@ttilberg ttilberg force-pushed the 512-set_proxy-prepends-value-with-http-regardless-of-what-is-passed-in branch from ac2911d to 983f53c Compare December 8, 2017 20:51
@knu knu merged commit 983f53c into sparklemotion:master Jun 2, 2018
knu added a commit that referenced this pull request Jun 2, 2018
@ttilberg ttilberg deleted the 512-set_proxy-prepends-value-with-http-regardless-of-what-is-passed-in branch June 27, 2018 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants