downthemall / anticontainer

DownThemAll! AntiContainer (Extension to a Firefox, Seamonkey extension)
Mozilla Public License 2.0
93 stars 41 forks source link

url: replacement parameter #7

Closed poke closed 13 years ago

poke commented 13 years ago

Originally created to collect some new plugins I am working on, this branch is now serving as a new feature holder :P

The {url:X} replacement parameter works the same as the {num:0} one but uses the match object created from the plugin's match parameter. It can be useful to use parts from the original URL, for example to resolve local URLs correctly within the plugin (without having to hardcode the address of course).

To access the match, I had to store it somewhere in between, and I just did that when testing the URL. So we don't have to rematch the URL again just because we want the match for the replacement. Having the previous match result should be good enough there.

Also I removed the empty check in the num: operator, because it doesn't make much sense to not allow an empty result. I can actually think of situations where adding a parameter, that might be empty, would be useful. And at least allowing empty results should not break any previous plugins.

Oh, and this pull request also includes the fix I already requested for the 0.9.x branch. I noticed that while testing the url: operator when it was combined with a normal num: operator.

poke commented 13 years ago

Okay, is this fix okay? Then you can close this pull request and I'll rebase the commits and open a new pull request (so that the line comments remain).

nmaier commented 13 years ago

Yeah, looks fine now. Go ahead, and rebase this and post another pr. Closing this one ;)