Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Arentsen committed Jan 22, 2019
2 parents 2718f1e + a9bebe4 commit 06676ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/liquid/filters.ex
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ defmodule Liquid.Filters do

def url_encode(nil), do: nil

def url_decode(input) when is_binary(input) do
input |> URI.decode_www_form()
end

def url_decode(nil), do: nil

def date(input, format \\ "%F %T")

def date(nil, _), do: nil
Expand Down
5 changes: 5 additions & 0 deletions test/liquid/filter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ defmodule Liquid.FilterTest do
assert nil == Functions.url_encode(nil)
end

test :url_decode do
assert "[email protected]" == Functions.url_decode("foo%2B1%40example.com")
assert nil == Functions.url_decode(nil)
end

test :truncatewords do
assert "one two three" == Functions.truncatewords("one two three", 4)
assert "one two..." == Functions.truncatewords("one two three", 2)
Expand Down

0 comments on commit 06676ce

Please sign in to comment.