From 944c00f290aac0436168879c71faf2aab651cfe0 Mon Sep 17 00:00:00 2001 From: Philip Sampaio Date: Wed, 25 Oct 2023 16:00:51 -0300 Subject: [PATCH] Rollback guard that requires only binary for parsing It allows iodata() to be used. This is a fix for the following comment: https://github.com/philss/floki/commit/0030b78f2afa6448a68cdee70b61677e2243b1b4#r130864052 --- lib/floki/html_parser.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/floki/html_parser.ex b/lib/floki/html_parser.ex index d94c729d..54362ab6 100644 --- a/lib/floki/html_parser.ex +++ b/lib/floki/html_parser.ex @@ -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()) @@ -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) @@ -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)