alex35mil / sourcebuster-js

Track the sources of your traffic
https://alexfedoseev.github.io/sbjs
MIT License
412 stars 92 forks source link

Query string parser generates array as value #38

Open rinu opened 3 years ago

rinu commented 3 years ago

src/js/helpers/uri.js:44 generates an array when multiple values exist with the same key.

An exmaple URL would be http://example.com/?utm_source=google&utm_source=google

The uri helper generates an array of ["google", "google"] for utm_source which gets cast to a string later via string concatenation.

The end result when I access sbjs.get.current.src is "google,google" which is not what you would expect.

The expected result would be to ignore the duplicate values and sbjs.get.current.src should just be "google".

Cooluck commented 3 years ago

Pardon for interruption, but the expected url is http://example.com/?utm_source=google And if you use a non-common utm-doubling it's easier to fix on your backend / frontend than develop such exception for sbjs.

вт, 22 июн. 2021 г. в 14:14, Rauno Moisto @.***>:

src/js/helpers/uri.js:44 generates an array when multiple values exist with the same key.

An exmaple URL would be http://example.com/?utm_source=google&utm_source=google

The uri helper generates an array of ["google", "google"] for utm_source which gets cast to a string later via string concatenation.

The end result when I access sbjs.get.current.src is "google,google" which is not what you would expect.

The expected result would be to ignore the duplicate values and sbjs.get.current.src should just be "google".

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/alexfedoseev/sourcebuster-js/issues/38, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNDX6XUW5DBOWT5PN5ZIITTUBWDFANCNFSM47DO2ZUQ .

--

С уважением, Роман Рыбальченко.

Основатель Roman.ua https://roman.ua/

Google Ads & Analytics Individual Qualified. MailChimp Expert.

C 2011 по 2013 — 1 из 3-х сертифицированных консультантов по Google Ads в Украине.

Рекомендую базу знаний об интернет-маркетинге http://roman.ua/baza-znanij/ и подкаст «Продуктивный Роман https://roman.ua/category/podcast/».

rinu commented 3 years ago

I agree that who ever set up the google integration for the project I'm working is an idiot for duplicating everything and that absolutely needs fixing.

Still, it was very difficult to debug and sbjs should not rely on magically casting arrays to string. It should also use a standard query string parser rather than a custom one. These are just bad practises and should eventually be fixed in this project as well.