Skip to content

Commit

Permalink
Rollback guard that requires only binary for parsing
Browse files Browse the repository at this point in the history
It allows iodata() to be used.

This is a fix for the following comment:
0030b78#r130864052
  • Loading branch information
philss committed Oct 25, 2023
1 parent 03c2b5a commit 944c00f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/floki/html_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule Floki.HTMLParser do
@default_parser Floki.HTMLParser.Mochiweb

@typep result(success) :: {:ok, success} | {:error, String.t()}
@typep html :: binary()
@typep html :: binary() | iodata()

@callback parse_document(html(), Keyword.t()) :: result(Floki.html_tree())
@callback parse_fragment(html(), Keyword.t()) :: result(Floki.html_tree())
Expand All @@ -35,7 +35,7 @@ defmodule Floki.HTMLParser do
@callback parse_fragment_with_attributes_as_maps(html(), Keyword.t()) ::
result(Floki.html_tree())

def parse_document(html, opts \\ []) when is_binary(html) do
def parse_document(html, opts \\ []) do
{parser_args, opts} = Keyword.pop(opts, :parser_args, [])

parser = parser(opts)
Expand All @@ -47,7 +47,7 @@ defmodule Floki.HTMLParser do
end
end

def parse_fragment(html, opts \\ []) when is_binary(html) do
def parse_fragment(html, opts \\ []) do
{parser_args, opts} = Keyword.pop(opts, :parser_args, [])

parser = parser(opts)
Expand Down

0 comments on commit 944c00f

Please sign in to comment.