   end
 
   defp compile_host_regex(host) do
-    host_pattern =
-        host
-        |> Regex.escape()
-        |> String.replace("%", ".*")
-        |> String.replace("_", ".{1}") # TODO: Paths like /my_path/ will match /myXpath/ which is BAD
-
+    host_pattern = prepare_regex(host)
     Regex.compile!("^#{host_pattern}$")
   end
 

  end

  defp compile_path_regex(path) do
    path_pattern =
      path
      |> Regex.escape()
      |> String.replace("%", ".*")
      |> String.replace("_", ".{1}")

    Regex.compile!("^#{path_pattern}")
  end


      Regex.match?(path_regex, path)
    end)
  end

  defp prepare_regex(string) do
    string
    |> Regex.escape()
    |> String.replace("%", ".*")
    |> String.replace("_", ".{1}") # TODO: Paths like /my_path/ will match /myXpath/ which is BAD
  end
end
