Skip to content

Commit

Permalink
Fix filter_by_prefix malformed case
Browse files Browse the repository at this point in the history
The filter must have the prefix presence, not the other way around
  • Loading branch information
edgurgel committed Feb 22, 2015
1 parent f16684b commit a20520b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/poxa/channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ defmodule Poxa.Channel do
false
iex> Poxa.Channel.matches?("foo-bar", "")
false
iex> Poxa.Channel.matches?("foo-bar", nil)
false
iex> Poxa.Channel.matches?("foo-bar", "foo-bartman")
false
"""
def matches?(_, nil), do: false
def matches?(_, ""), do: false
def matches?(channel, prefix) do
base = byte_size(prefix)
Expand Down
2 changes: 1 addition & 1 deletion lib/poxa/channels_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ defmodule Poxa.ChannelsHandler do
defp malformed_request_all_channels?(attributes, filter) do
if Enum.all?(attributes, fn s -> Enum.member?(@valid_attributes, s) end) do
if Enum.member?(attributes, "user_count") do
filter == nil or !Channel.matches?("presence-", filter)
!Channel.matches?(filter, "presence-")
else
false
end
Expand Down

0 comments on commit a20520b

Please sign in to comment.