gyng / save-in

WebExtension for saving media, links, or selections into user-defined directories
MIT License
208 stars 26 forks source link

Regex to remove 'http://' and 'https://' from final filenames? #209

Open rudolphos opened 10 months ago

rudolphos commented 10 months ago

I have a rule that renames files like this:

// website.com* rule
pagedomain: website.com*
into: :pageurl:_:pagetitle:_:filename:

But files are saved with https___. How can I exclude this part?

I tried regex [A-Za-z]+:// and [A-Za-z]+_+ that would select the part to exclude from final :pageurl: but I can't find an option to omit certain text in this extension.

gyng commented 10 months ago

capture can be used here:

pagedomain: website.com*
sourceurl: https://(.*)
capture: sourceurl
into: :$1:_:pagetitle:_:filename:

https://upload.wikimedia.org/wikipedia/commons/thumb/6/67/Harry_S._Truman_-_NARA_-_530677_crop.jpg/206px-Harry_S._Truman_-_NARA_-_530677_crop.jpg becomes 206px-Harry_S._Truman_-_NARA_-_530677_crop.jpg_Wikipedia, the free encyclopedia_206px-Harry_S._Truman_-_NARA_-_530677_crop.jpg in this case. Although the slashes might mess things up. In that scenario there isn't a solution for that.