Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

pageDefaults.searchPath drops last character in query string #28

@perryao

Description

@perryao

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions