segmentio/analytics.js-core

pageDefaults.searchPath drops last character in query string

Closed this issue · 1 comments

The current implementation of pageDefaults.searchPath removes the last character in the query string. https://github.com/segmentio/analytics.js-core/blob/master/lib/pageDefaults.js#L70. The second parameter to url.slice is -1, which specifies to drop the last character.

Docs for String.prototype.slice: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice

Example

var url = 'https://github.com/segmentio/analytics.js-core?param=test';
var u = url.indexOf('?');
var result = u === -1 ? '' : url.slice(u, -1); // returns ?param=tes

Expected

var url = 'https://github.com/segmentio/analytics.js-core?param=test';
var u = url.indexOf('?');
var result = u === -1 ? '' : url.slice(u); // returns ?param=test

I can make the change and submit a pull request if you'd like.

hey @perryao, sorry for the delay here. Thanks for spotting this; I've reverted the change that cause this regression for now #51 to fix the issue so you won't see the truncation anymore.