pageDefaults.searchPath drops last character in query string
Closed this issue · 1 comments
perryao commented
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.