From da71fb6d2c9e0a607376b5bb945c80ffc9e18b9b Mon Sep 17 00:00:00 2001 From: Kevin Pan Date: Wed, 1 Mar 2023 15:52:49 +0800 Subject: [PATCH] Fix protected check in Gettext.Extractor (#357) --- lib/gettext/extractor.ex | 2 +- test/gettext/extractor_test.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gettext/extractor.ex b/lib/gettext/extractor.ex index 46d78057..a29bf2a1 100644 --- a/lib/gettext/extractor.ex +++ b/lib/gettext/extractor.ex @@ -422,5 +422,5 @@ defmodule Gettext.Extractor do do: false defp protected?(%{references: refs}, pattern), - do: Enum.any?(refs, fn {path, _} -> Regex.match?(pattern, path) end) + do: refs |> List.flatten() |> Enum.any?(fn {path, _} -> Regex.match?(pattern, path) end) end diff --git a/test/gettext/extractor_test.exs b/test/gettext/extractor_test.exs index 60df837e..ba885825 100644 --- a/test/gettext/extractor_test.exs +++ b/test/gettext/extractor_test.exs @@ -91,7 +91,7 @@ defmodule Gettext.ExtractorTest do message_1 = %Message.Singular{ msgid: ["foo"], msgstr: ["bar"], - references: [{"foo.ex", 1}], + references: [[{"foo.ex", 1}, {"bar.ex", 1}], [{"baz.ex", 1}]], flags: [["elixir-autogen", "elixir-format"]] }