Created
May 16, 2018 08:57
-
-
Save keshcreations/d2d8b1855a81d99905b1c164317f496e to your computer and use it in GitHub Desktop.
JavaScript for encoding URL with invalid characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//setEventCallback That on campaign open or feedback open will retrieve the URL en encode it to make sure that non-encoded characters cause issues for using Usabilla. | |
window.usabilla_live("setEventCallback", function(category, action, label, value) { | |
var type = null; | |
var uri = ""; | |
var res = ""; | |
switch (action) { | |
case "Feedback:Open": | |
uri = window.location; | |
res = encodeURI(uri); | |
history.pushState('', document.title, res); | |
break; | |
case "Campaign:Open": | |
uri = window.location; | |
res = encodeURI(uri); | |
history.pushState('', document.title, res); | |
history.pushState('', document.title, res); | |
break; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment