null-dev / DynamicHistory

Automagically delete browsing history based on the content of the page!
MIT License
20 stars 3 forks source link

Support for file:// URLs #21

Closed terminalmage closed 6 years ago

terminalmage commented 6 years ago

Since this extension matches on domain, I've been able to match file:// URLs (e.g. file:///tmp/somefile) to work by using the regex ^/. However, this blocks all file:// URLs, and I don't necessarily want to block all of them. I really just want to block ones in /tmp as they represent files that aren't likely to persist and thus don't need to remain in my browsing history.

It would be nice to have more flexible support for these URLs.

terminalmage commented 6 years ago

Actually, I take it back... ^/ matches everything. So there is presently no way to match file:// URLs without blocking everything else as well.

null-dev commented 6 years ago

Depending on what URLs you want to match, you can use the following regexes:

file:\/\/tmp.* to match file://tmp/whatever (two slashes) file:\/\/\/tmp.* to match file:///tmp/whatever (three slashes)

You must also enable the "Check entire URL" option or else DynamicHistory will just attempt to match the regexes to the domain (and there is no domain on file URLs).

If you are on Chrome, you can alternatively add the following code into the "Custom history processor" box:

//Remove URLs that start with "file://tmp" or "file:///tmp"
if(item.url.startsWith("file://tmp")
    || item.url.endsWith("file:///tmp"))
    item.remove();
terminalmage commented 6 years ago

Thanks for the info. I'm not used to having to escape slashes on simple regex searches, so I didn't think to escape them.

However, this doesn't work the way you said it does. First of all, three escaped backslashes do not work. So, file:\/\/tmp.* works, while file:\/\/\/tmp.* does not.

Secondly, slashes can't be matched after the beginning of the path. So I can use file:\/\/home.*, but I can't use file:\/\/home\/.*.

null-dev commented 6 years ago

Alright, nice job noticing that! I've just checked and that's a bug with my regex processing algorithm. I'll try to fix it today if possible.

null-dev commented 6 years ago

Alright, updated version 2.17 pushed out with a fix. Please re-open if it does not fix the issue.

terminalmage commented 6 years ago

Excellent, thanks!

terminalmage commented 6 years ago

Fix confirmed :+1: