Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function removeURLParameter(url, parameter) {
- //prefer to use l.search if you have a location/link object
- var urlparts= url.split('?');
- if (urlparts.length>=2) {
- var prefix= encodeURIComponent(parameter)+'=';
- var pars= urlparts[1].split(/[&;]/g);
- //reverse iteration as may be destructive
- for (var i= pars.length; i-- > 0;) {
- //idiom for string.startsWith
- if (pars[i].lastIndexOf(prefix, 0) !== -1) {
- didRemoveURLParameter = true;
- pars.splice(i, 1);
- }
- }
- url= urlparts[0] + (pars.length > 0 ? '?' + pars.join('&') : "");
- return url;
- } else {
- return url;
- }
- }
- // We want to remove the `rl` parameter from the URL if it is present so that the RedirectURL is properly handled.
- // This also allows us not to rely on forcing users to come to the form(s) via formula - url fields, which allows for more native navigation of the apps.
- var url = window.location.href,
- didRemoveURLParameter = false,
- urlParams = new URLSearchParams(window.location.search),
- cleanedURL = removeURLParameter(url, "rl");
- // Check to make sure we are editing the record
- var isEditing = false;
- if(urlParams.has("a") && urlParams.get("a") == "er") isEditing = true;
- if(didRemoveURLParameter && isEditing) window.location.replace(cleanedURL, false);
Advertisement
Add Comment
Please, Sign In to add comment