added a test and changed hashmode condition (#2082)

This commit is contained in:
RobertJoonas 2022-08-09 14:31:37 +03:00 committed by GitHub
parent 99fd101135
commit a058cf6240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -273,7 +273,7 @@ defmodule PlausibleWeb.Api.ExternalController do
|> URI.decode()
|> String.trim_trailing()
if hash_mode && uri.fragment do
if hash_mode == 1 && uri.fragment do
pathname <> "#" <> URI.decode(uri.fragment)
else
pathname

View File

@ -842,6 +842,22 @@ defmodule PlausibleWeb.Api.ExternalControllerTest do
assert pageview.pathname == "/#page-a"
end
test "does not record hash when hash mode is 0", %{conn: conn} do
params = %{
n: "pageview",
u: "http://www.example.com/#page-a",
d: "external-controller-test-hash-0.com",
h: 0
}
conn
|> post("/api/event", params)
pageview = get_event("external-controller-test-hash-0.com")
assert pageview.pathname == "/"
end
test "decodes URL pathname, fragment and search", %{conn: conn} do
params = %{
n: "pageview",