Repository navigation
fix: save the first nonempty value of a repeated query parameter - #230
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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=googlesavedgoogle,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=newslettersavesgoogle. 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:
On the unchanged parser, 6 cases fail, for example
expected { fbclid: ',,meta-click' } to deeply equal { fbclid: 'meta-click' }. With the change, all 46utm.test.tscases pass.Validation:
pnpm format:check,pnpm lint --max-warnings 0, andpnpm testpass.