Last active
August 14, 2020 02:30
-
-
Save dsottimano/28b709874810da637e9ad8372c1105b1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function REMOVE_SPECIFIC_QUERY(url,queriesToRemove) { | |
try { | |
if (!url) return "Error: Missing parameter. To Fix: Ensure you have both parameters set"; | |
if (url.map) url.map(u=> REMOVE_QUERY(u)) | |
else { | |
let result = "?hello=hi&ga=123" | |
//if (!result.includes("&")) return url.replace("?" + result,""); | |
result = result.split("&") | |
queriesToRemove = queriesToRemove.split(",") | |
result = result.filter(function(item) { | |
console.log(queriesToRemove.map(q=> q.includes(item))) | |
return !queriesToRemove.includes(item); | |
}) | |
return result | |
} | |
} catch(e) { | |
return e.toString(); | |
} | |
} | |
console.log(REMOVE_SPECIFIC_QUERY("https://example.com?hello=hi&ga=123","hello")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment