Url cleaning notes

I started looking into how to develop a “link cleaning” feature and it’s a lot more complicated than I originally anticipated.

Firefox has two different lists, one licensed under the LGPL and the other under the MPL2 but they have variations so we’d need to load both.

Brave uses a single file, licensed under MPL2, which is fine for us, that uses a regex syntax. Their algorithm appears to check the url against all patterns, skipping ones that make the exclude pattern, and then remove the specified params.

We will probably use the brave file as the source as it’s just easier to work with it.

Overall, right now I’m leaning towards a separate library for this and only this as url cleanup is something useful to a lot of applications, so having all of the other stuff from birb from example would be a bit much. Also this needs to load a bunch of data at startup and have a way to tear it down at shutdown and birb doesn’t have that right now.

I’m thinking we’ll just commit the file directly to the repo, maintaining the license as it will be unedited, then adding it to a resource that will be loaded at startup via an init method and freed via a uninit method. This would require json-glib and glib but that should be all that is necessary.

Later on, we can add support for removing tracking parameters. Brave has some good documentation on that as well.

Looking through those it seems like the lists were originally all sourced from outside sources.

I assume the Firefox list is separated in two due to sourcing the original data, although ⚙ D203080 Bug 1859353 - Part 1: Added more query params in LGPL license specific file.r=pbz doesn’t say too much besides someone checked w/ Mozilla legal. The bug itself mentions GitHub - Smile4ever/Neat-URL: Neat URL cleans URLs, removing parameters such as Google Analytics' utm parameters. · GitHub but unsure if that’s actually the source.

Brave’s seems like a derivative of AdGuard’s list: Initial clean-urls.json list · brave/adblock-lists@b4bc704 · GitHub


Both LGPL-2.0 and MPL-2.0 should be compatible with GPL-2.0 so any/all of them are acceptable.

The rest of the plan seems reasonable, minus that you’ll likely want to keep the file in sync periodically. (This points to not wanting to modify it and using it directly as you mention!)

1 Like

Thanks for the additional information!