keichan34 / exfile

File upload persistence and processing for Phoenix / Plug
MIT License
90 stars 19 forks source link

Remove unnecessary condition from pattern matching #39

Closed asiniy closed 8 years ago

asiniy commented 8 years ago

I think it's not needed here. WDYT?

keichan34 commented 8 years ago

Hmm.. well, is_atom(nil) is true, so I wanted to be extra sure. I see that if endpoint is nil in that function, it will call Phoenix.Router.Helpers.url(nil, nil), which results in an error:

iex(1)> Phoenix.Router.Helpers.url(nil, nil)
** (UndefinedFunctionError) function nil.url/0 is undefined or private
    nil.url()

I think we can leave it in, and if there's a case where endpoint is nil, show a more descriptive error message? With the current implementation there is just the match error. What do you think?

asiniy commented 8 years ago

@keichan34 kinda unpredictable behaviour of is_atom(true) here. You're absolutely right here, I'm closing the PR.

By the way, I asked a question at SO: http://stackoverflow.com/questions/38852905/why-is-atomnil-equals-to-true-in-elixir