File tree Expand file tree Collapse file tree 3 files changed +38
-4
lines changed
Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -274,6 +274,7 @@ const queryStringParser = (
274274) : Dictionary < string > => {
275275 let urlParams : URLSearchParams | URLSearchParamsFallback ;
276276 let results : Dictionary < string > = { } ;
277+ let lowerCaseUrlParams : Dictionary < string > = { } ;
277278
278279 if ( ! url ) return results ;
279280
@@ -284,13 +285,15 @@ const queryStringParser = (
284285 urlParams = queryStringParserFallback ( url ) ;
285286 }
286287
288+ urlParams . forEach ( ( value , key ) => {
289+ lowerCaseUrlParams [ key . toLowerCase ( ) ] = value ;
290+ } ) ;
291+
287292 if ( isEmpty ( keys ) ) {
288- urlParams . forEach ( ( value , key ) => {
289- results [ key ] = value ;
290- } ) ;
293+ return lowerCaseUrlParams ;
291294 } else {
292295 keys . forEach ( key => {
293- const value = urlParams . get ( key ) ;
296+ const value = lowerCaseUrlParams [ key . toLowerCase ( ) ] ;
294297 if ( value ) {
295298 results [ key ] = value ;
296299 }
Original file line number Diff line number Diff line change @@ -145,6 +145,20 @@ describe('Integration Capture', () => {
145145 ScCid : '1234' ,
146146 } ) ;
147147 } ) ;
148+
149+ it ( 'should capture Snapchat specific click ids without being case sensitive' , ( ) => {
150+ const url = new URL ( 'https://www.example.com/?sccid=1234' ) ;
151+
152+ window . location . href = url . href ;
153+ window . location . search = url . search ;
154+
155+ const integrationCapture = new IntegrationCapture ( ) ;
156+ integrationCapture . capture ( ) ;
157+
158+ expect ( integrationCapture . clickIds ) . toEqual ( {
159+ ScCid : '1234' ,
160+ } ) ;
161+ } ) ;
148162 } ) ;
149163
150164 describe ( 'Facebook Click Ids' , ( ) => {
Original file line number Diff line number Diff line change @@ -173,6 +173,23 @@ describe('Utils', () => {
173173
174174 expect ( queryStringParser ( malformedUrl , keys ) ) . toEqual ( expectedResult ) ;
175175 } ) ;
176+
177+ it ( 'should handle different params case sensitivity and return them as lowercased params' , ( ) => {
178+ const url = 'https://www.example.com?FoO=bar&bAz=qux&NARF=poit'
179+ const keys = [
180+ 'foo' ,
181+ 'baz' ,
182+ 'narf' ,
183+ ] ;
184+
185+ const expectedResult = {
186+ foo : 'bar' ,
187+ narf : 'poit' ,
188+ baz : 'qux' ,
189+ } ;
190+
191+ expect ( queryStringParser ( url , keys ) ) . toEqual ( expectedResult ) ;
192+ } ) ;
176193 } ) ;
177194 } ) ;
178195
You can’t perform that action at this time.
0 commit comments