Skip to content

Commit

Permalink
Add clause for stripping integers
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurClemens committed May 10, 2014
1 parent 914b7f6 commit a1f8d44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/z_html.erl
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ strip([]) ->
strip(Html) when is_binary(Html) ->
strip(Html, in_text, <<>>);
strip(L) when is_list(L) ->
strip(list_to_binary(L)).
strip(list_to_binary(L));
strip(N) when is_integer(N) ->
strip(integer_to_list(N)).

strip(<<>>, _, Acc) -> Acc;
strip(<<$<,T/binary>>, in_text, Acc) ->
Expand Down
4 changes: 4 additions & 0 deletions test/z_html_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ ensure_check_test() ->

strip_test() ->
?assertEqual(<<"Hello">>, z_html:strip(<<"<p class='hello'>Hello</p>">>)),
?assertEqual(<<"Hello">>, z_html:strip(<<"Hello">>)),
?assertEqual(<<"">>, z_html:strip(<<"">>)),
?assertEqual([], z_html:strip([])),
?assertEqual(<<"1234">>, z_html:strip(1234)),
ok.

abs_links_test() ->
Expand Down

0 comments on commit a1f8d44

Please sign in to comment.