CleverTap / clevertap-web-sdk

CleverTap Web SDK
https://clevertap.com/
MIT License
14 stars 18 forks source link

BugFix #Web-42 Globally replace '##campaignId' in the web popup HTML template #30

Closed AmeeBhadania closed 3 years ago

AmeeBhadania commented 3 years ago

Analysis

At the time of rendering the webpopup, in order to replace the string '##campaignId##' with the correct one, we have html = html.replace('##campaignId##', campaignId)

This works well for the existing web templates where we just have 1 occurrence of the string '##campaignId##' linked to the close button.

For the user ratings template, where we have 2 occurrences of the string '##campaignId##' (one in handler for close button and another in the onclick handler of submit button), only the 1st occurrence is getting replaced.

Resolution

Changed the logic to html = html.replace(/##campaignId##/g, campaignId)

UT has been done to ensure that both the occurrences of the string '##campaignId##' in the User Ratings template are getting replaced correctly.

Aditi3 commented 3 years ago

@akashvercetti Have a look at the changes and merge it to develop if looks good to you!