Verification: prioritize domain mismatch over multiple snippets (#4146)

This commit is contained in:
hq1 2024-05-27 10:52:22 +02:00 committed by GitHub
parent 0381bc6121
commit 78c5762761
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 4 deletions

View File

@ -187,6 +187,10 @@ defmodule Plausible.Verification.Diagnostics do
error(@errors.proxy_general)
end
def interpret(%__MODULE__{data_domain_mismatch?: true}, "https://" <> domain) do
error(@errors.different_data_domain, domain: domain)
end
def interpret(
%__MODULE__{snippets_found_in_head: count_head, snippets_found_in_body: count_body},
_url
@ -238,10 +242,6 @@ defmodule Plausible.Verification.Diagnostics do
error(@errors.snippet_in_body)
end
def interpret(%__MODULE__{data_domain_mismatch?: true}, "https://" <> domain) do
error(@errors.different_data_domain, domain: domain)
end
def interpret(
%__MODULE__{
plausible_installed?: false,

View File

@ -671,6 +671,27 @@ defmodule Plausible.Verification.ChecksTest do
assert_receive :redirect_sent
end
@many_snippets_with_domain_mismatch """
<html>
<head>
<script defer data-domain="example.org" src="https://plausible.io/js/script.js"></script>
<script defer data-domain="example.org" src="https://plausible.io/js/script.js"></script>
</head>
<body>
Hello
</body>
</html>
"""
test "prioritizes data-domain mismatch over multiple snippets" do
stub_fetch_body(200, @many_snippets_with_domain_mismatch)
stub_installation()
run_checks()
|> Checks.interpret_diagnostics()
|> assert_error(@errors.different_data_domain, domain: "example.com")
end
end
defp run_checks(extra_opts \\ []) do