It would feel more Elixir like if you write both this and the next `if`s as case expressions. For example:

    case filter do
      "~" <> filter ->
        exclude = true
      _ ->
        exclude = false
    end

Please give it a try. :) Btw, we could also make this function public and documented. :)