Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #3083 improve the parseURL function to handle page-relative URLs #3087

Merged
merged 2 commits into from
Dec 4, 2024

Conversation

Kilian
Copy link
Contributor

@Kilian Kilian commented Dec 4, 2024

In #3083 I noticed that some of my hash URLs were tracked without including the path. Upon inspection I found out that the parseURL implementation included a bug: it resolved against origin and not against href, which means that page-relative URLs coming from pushState are resolved incorrectly.

The following links all resolve to the same page:

  • fully specified: https://example.com/foo/bar
  • relative to the root: /foo/bar
  • relative to the current page: ../bar when you're on https://example.com/foo/baz

When using origin the last one will resolve incorrectly (it will try to go a subfolder higher than the origin), as it should be compared to the current href.

This URL resolution is also why pushstate can contain just #selector=foo and resolve correctly against the current page.

Fixes #3083.

Copy link

vercel bot commented Dec 4, 2024

@Kilian is attempting to deploy a commit to the umami-software Team on Vercel.

A member of the Team first needs to authorize it.

src/tracker/index.js Outdated Show resolved Hide resolved
@mikecao mikecao changed the base branch from master to dev December 4, 2024 18:04
@mikecao mikecao merged commit 6b1c183 into umami-software:dev Dec 4, 2024
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hash changes are reported on the wrong URL
2 participants