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

Add Plug.Conn.request_url/1 #588

Merged
merged 2 commits into from Aug 24, 2017
Merged

Conversation

henrik
Copy link
Contributor

@henrik henrik commented Aug 23, 2017

As discussed in #587.

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)]
Copy link
Member

Choose a reason for hiding this comment

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

Integer.to_string(port)?

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

@henrik henrik Aug 24, 2017

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.

Copy link
Member

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!

@josevalim josevalim merged commit 383a5e4 into elixir-plug:master Aug 24, 2017
@josevalim
Copy link
Member

❤️ 💚 💙 💛 💜

@henrik
Copy link
Contributor Author

henrik commented Aug 24, 2017

Perfect, thank you @josevalim! 💓

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

2 participants