Skip to content

fix: save the first nonempty value of a repeated query parameter - #230

Merged
sadjow merged 2 commits into
mainfrom
fix/repeated-query-params
Oct 15, 2026
Merged

sadjow merged 2 commits into
mainfrom
fix/repeated-query-params

Conversation

@sadjow

@sadjow sadjow commented Oct 14, 2026

Copy link
Copy Markdown
Member

Vue Router parses a query parameter that appears more than once into an array, and the module turned that array into a comma-joined string. ?utm_source=google&utm_source=google saved google,google. An array whose entries were all empty, such as ?utm_source=&utm_source=, still counted as a campaign visit, because a non-empty array is truthy.

Each UTM field, Google click field, and configured click parameter now keeps its first nonempty value. This works like URLSearchParams.get, except that empty entries are skipped so they can't hide a later value: ?utm_source=&utm_source=google&utm_source=newsletter saves google. When every entry is empty, the field keeps the first one, so the visit reads like a single empty parameter and is not a campaign. The README's description of the entry fields explains the rule.

This changes stored values, so it needs a release note. Entries saved earlier keep their stored values, and no migration is needed.

The unit tests replace the comma-joined expectations. New cases cover:

  • an identical repeated value saved once
  • the first of two different values kept
  • null and empty entries skipped before the first nonempty value
  • entries that are all empty not counted as a campaign

On the unchanged parser, 6 cases fail, for example expected { fbclid: ',,meta-click' } to deeply equal { fbclid: 'meta-click' }. With the change, all 46 utm.test.ts cases pass.

Validation: pnpm format:check, pnpm lint --max-warnings 0, and pnpm test pass.

@sadjow
sadjow merged commit 98a3ab1 into main Oct 15, 2026
7 checks passed
@sadjow
sadjow deleted the fix/repeated-query-params branch October 15, 2026 01:27
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.

1 participant