I’m trying to clear the url parameters using a javascript code in a smart rule, but without success.
The idea would be to eliminate everything that comes after the ?
in a URL, including the ?
.
This is the javascript code I’m using within the action “Apply Script - Javascript”:
function performsmartrule(records) {
var app = Application("DEVONthink 3");
app.includeStandardAdditions = true;
records.forEach (r => {
const URL = r.url();
const cleanUrl = URL.match(/([^\?]*).*$/);
if (result !== null) {
r.url = cleanUrl;
}
})
}
An example of a URL to be cleaned:
mywebsite.com/sale?utm_campaign=20_off&utm_medium=paid&utm_source=instagram&utm_content=bio
Desired result:
mywebsite.com/sale
Nothing happens to the bookmark url when I trigger the smart rule