mirror of
https://github.com/plausible/analytics.git
synced 2024-08-17 05:40:24 +03:00
Require src attribute when seeking snippet for verification (#4290)
This commit is contained in:
parent
8188006c45
commit
f4e091452c
@ -11,8 +11,8 @@ defmodule Plausible.Verification.Checks.Snippet do
|
||||
|
||||
@impl true
|
||||
def perform(%State{assigns: %{document: document}} = state) do
|
||||
in_head = Floki.find(document, "head script[data-domain]")
|
||||
in_body = Floki.find(document, "body script[data-domain]")
|
||||
in_head = Floki.find(document, "head script[data-domain][src]")
|
||||
in_body = Floki.find(document, "body script[data-domain][src]")
|
||||
|
||||
all = in_head ++ in_body
|
||||
|
||||
|
@ -246,6 +246,26 @@ defmodule Plausible.Verification.ChecksTest do
|
||||
|> assert_error(@errors.multiple_snippets)
|
||||
end
|
||||
|
||||
@no_src_scripts """
|
||||
<html>
|
||||
<head>
|
||||
<script defer data-domain="example.com"></script>
|
||||
</head>
|
||||
<body>
|
||||
Hello
|
||||
<script defer data-domain="example.com"></script>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
test "no src attr doesn't count as snippet" do
|
||||
stub_fetch_body(200, @no_src_scripts)
|
||||
stub_installation(200, plausible_installed(false))
|
||||
|
||||
run_checks()
|
||||
|> Checks.interpret_diagnostics()
|
||||
|> assert_error(@errors.no_snippet)
|
||||
end
|
||||
|
||||
@many_snippets_ok """
|
||||
<html>
|
||||
<head>
|
||||
|
Loading…
Reference in New Issue
Block a user