diff --git a/lib/boundary/checker.ex b/lib/boundary/checker.ex index 7e6654d..f1c8e5e 100644 --- a/lib/boundary/checker.ex +++ b/lib/boundary/checker.ex @@ -127,8 +127,14 @@ defmodule Boundary.Checker do |> Stream.take_while(&(not is_nil(&1))) |> Enum.find(&(Enum.at(&1.ancestors, 0) == boundary.name)) |> case do - nil -> false - child_subboundary -> export in [child_subboundary.name | child_subboundary.exports] + nil -> + false + + %{exports: [{_, []}]} = child_subboundary -> + String.starts_with?(to_string(export), to_string(child_subboundary.name)) + + child_subboundary -> + export in [child_subboundary.name | child_subboundary.exports] end end end @@ -331,10 +337,6 @@ defmodule Boundary.Checker do defp export_matches?(_view, _boundary, module, module), do: true - defp export_matches?(_view, _boundary, {root, []}, module) do - String.starts_with?(to_string(module), to_string(root)) - end - defp export_matches?(view, boundary, {root, opts}, module) do String.starts_with?(to_string(module), to_string(root)) and not Enum.any?(Keyword.get(opts, :except, []), &(Module.concat(root, &1) == module)) and diff --git a/test/mix/tasks/compile/boundary_test.exs b/test/mix/tasks/compile/boundary_test.exs index 782fe3d..8329b44 100644 --- a/test/mix/tasks/compile/boundary_test.exs +++ b/test/mix/tasks/compile/boundary_test.exs @@ -1154,14 +1154,16 @@ defmodule Mix.Tasks.Compile.BoundaryTest do defmodule Schemas.Foo do def fun(), do: :ok end defmodule Schemas.Bar do def fun(), do: :ok end - end - defmodule #{module1}.Subdomain do - use Boundary, exports: :all - end + defmodule Subdomain do + use Boundary, exports: :all - defmodule #{module1}.Subdomain.Module do - def fun(), do: :ok + def fun(), do: :ok + + defmodule Module do + def fun(), do: :ok + end + end end defmodule #{module2} do @@ -1171,6 +1173,7 @@ defmodule Mix.Tasks.Compile.BoundaryTest do #{module1}.Schemas.Foo.fun() #{module1}.Schemas.Bar.fun() #{module1}.Schemas.Base.fun() + #{module1}.Subdomain.fun() #{module1}.Subdomain.Module.fun() end end