Skip to content

Normalize trailing slashes in page URLs#301

Merged
yosriady merged 1 commit into
mainfrom
codex/normalize-trailing-slashes-in-page-urls
Jul 2, 2026
Merged

Normalize trailing slashes in page URLs#301
yosriady merged 1 commit into
mainfrom
codex/normalize-trailing-slashes-in-page-urls

Conversation

@yosriady

@yosriady yosriady commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • Analytics page URLs and page properties should be canonicalized so that routes with and without trailing slashes are deduplicated for reporting and dropdowns.
  • Trailing-slash normalization should not change the root / and must preserve query strings and hash fragments.

Description

  • Add a private normalizeUrlPath(url: URL) helper to strip trailing slashes from non-root pathnames and call it from redactUrl and the page-properties parsing path in getPageProperties (file src/event/EventFactory.ts).
  • Apply normalization when building the context page_url (via redactUrl) and when populating page properties so url/path reflect the normalized path while preserving ?query and #hash.
  • Use the parsed URL (urlObj.pathname) for pageProps.path instead of globalThis.location.pathname so the normalized pathname is used when available.
  • Add tests in test/lib/event/PagePropertiesParsing.spec.ts that assert non-root trailing-slash stripping (/limit/bnb//limit/bnb) and root-path preservation (/ remains /).

Testing

  • Ran lint with pnpm lint and it completed successfully.
  • Ran the page properties tests with pnpm test -- test/lib/event/PagePropertiesParsing.spec.ts and the tests (including the two new assertions) passed as part of the full suite (651 passing).

Codex Task


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

@yosriady yosriady merged commit 9374a25 into main Jul 2, 2026
11 checks passed
@yosriady yosriady deleted the codex/normalize-trailing-slashes-in-page-urls branch July 2, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant