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
Add Plug.Conn.request_url/1 #588
Conversation
lib/plug/conn.ex
Outdated
|
||
defp request_url_port(:http, 80), do: "" | ||
defp request_url_port(:https, 443), do: "" | ||
defp request_url_port(_, port), do: [?:, to_string(port)] |
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.
Integer.to_string(port)
?
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.
Will do, thanks. Because it saves the indirection of figuring out how to stringify it?
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.
The counter argument is that the code is now clearer because we always know port is an integer, we don't have to guess what types it may have.
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.
That's true. Haven't gotten around to changing it yet – want to leave it like this, then?
Personally I kind of like ":#{port}"
for readability and brevity, though I understand it may be less performant.
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.
No worries. I will go ahead and change it and merge then! Since I prefer the more explicit format. :) Thank you!
❤️ 💚 💙 💛 💜 |
Perfect, thank you @josevalim! 💓 |
As discussed in #587.