Skip to content

Commit 0053708

Browse files
decode query params (#590)
* decode query params * Add unit test * bump version
1 parent 6e49fae commit 0053708

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

integrations/segmentio/lib/utm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function utm(query) {
1717
if (utmParam === 'campaign') {
1818
utmParam = 'name'
1919
}
20-
acc[utmParam] = v
20+
acc[utmParam] = decodeURIComponent(v.replace(/\+/g, ' '))
2121
}
2222
}
2323

integrations/segmentio/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@segment/analytics.js-integration-segmentio",
33
"description": "The Segmentio analytics.js integration.",
4-
"version": "4.4.4",
4+
"version": "4.4.5",
55
"keywords": [
66
"analytics.js",
77
"analytics.js-integration",

integrations/segmentio/test/index.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@ describe('Segment.io', function() {
241241
Segment.global = window;
242242
});
243243

244+
it('should decode .campaign', function() {
245+
Segment.global = { navigator: {}, location: {} };
246+
Segment.global.location.search =
247+
'?utm_source=%5BFoo%5D';
248+
segment.normalize(object);
249+
analytics.assert(object);
250+
analytics.assert(object.context);
251+
analytics.assert(object.context.campaign);
252+
analytics.assert(object.context.campaign.source === '[Foo]');
253+
Segment.global = window;
254+
});
255+
244256
it('should allow override of .campaign', function() {
245257
Segment.global = { navigator: {}, location: {} };
246258
Segment.global.location.search =

0 commit comments

Comments
 (0)