URL Cleaner: Provide a way disable/overwrite default rules
Describe a related problem (optional)
Given that the ClearURL definitions are external, it's hard to provide custom updates to it without potentially losing it whenever there's a remote update that needs to be applied.
We do have the "Pattern checker" module, but it's not as powerful as the URL Cleaner as far as I'm aware.
Describe your suggested feature
We should be able to provide a custom clear URL definition which applies on top of the default upstream version.
I forsee this working by merging the top level providers such that if you have a custom provider called amazon defined, then that'll take precedence over whatever the default one does.
Describe alternatives you've considered for your suggested feature
No response
Other details
No response
Acknowledgements
- [x] I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open issue.
- [x] I have written a short but informative title.
- [x] I will fill out all of the requested information in this form.
If I'm understanding correctly, this is already possible. See #400 (selected answer).
Let me know if this solves your issue or not, so I can close this issue or see what we can do to improve the app!
Oh okay, don't know how I missed that, that's very useful, thanks!
That allows me to add new Clear URL rules without losing them with future updates, but not necessarily overriding the behaviour of the ones defined with the default providers, e.g. if certain query strings need to be persisted rather than cleared.
In order to support overriding the default matches, I think it might work a bit better by having the providers property loaded first, then anything else coming second, as well as populating the rules as a map to avoid duplications.
A new disabled option might also be useful to easily skip certain overridden rules.
Sure! Seems like a good idea.
A new overwrite option on any custom rule could disable future rules from the default database that have the exact same name. Not necessarily a boolean, as with multiple custom parent objects could get weird. Maybe something like, overwrite: no, default, all.
Exactly, the 'providers' top object will be updated, but you can add more. Thanks pablo!
As for the 'patching', the current code just iterates all rules in all top objects, but it can be easily changed to replace if the name is the same. Adding a new 'override' field could be a solution, but since this feature is basically only for overriding, I think it can be done by default.
What I'm thinking is that making it so that if you have something like
{
"providers":{
"amazon": {/*the original definition from the clearurl catalog*/}
},
"user":{
"amazon": {/*the user definition */}
}
}
then the original rules for amazon would be ignored and instead replaced with the user definition. (right now, in this situation, both definitions would be applied)
Would that be enough for you?
the original rules for amazon would be ignored and instead replaced with the user definition. (right now, in this situation, both definitions would be applied) Would that be enough for you?
Yes, that's the exact behaviour I was looking for! Giving how large the current JSON was, I was thinking it'd be a lot easier if the custom settings were defined in their own custom settings, but this works as well, as long as the custom settings are defined at the top of the file.