Closed ivanalejandro0 closed 7 years ago
Just FYI, since #2 the code in master doesn't use these regexes, and does not suffer from at least some of the issues that you are fixing here. Not saying that your PR is entirely useless, just wanted you be aware.
Hey @maximbaz thanks for the heads up!. I was checking the python code instead of the actual tmux/fzf behavior for those problems so I didn't realized.
They are matching because the plugin is extracting words (see extrakto.tmux
), not urls.
See this example:
➜ echo "lowercase sftp://site.com and UPPERCASE HTTP://GOOGLE.COM" | python extrakto.py -u
ftp://site.com
# this is what tmux/fzf uses right now
➜ echo "lowercase sftp://site.com and UPPERCASE HTTP://GOOGLE.COM" | python extrakto.py -w
lowercase
sftp://site.com
UPPERCASE
HTTP://GOOGLE.COM
So, even though users (most likely) won't experience the problem I mentioned, these are valid url regexp fixes.
Cheers!
Thanks, that's more than I would have done ;)
@maximbaz I think I should add options to make this configurable.
Up to you of course, but honestly I haven't seen a single case yet when I would be disappointed by the results discovered with the current "words" approach. I'm still keeping an eye on it 😉
That's true but extrakto.py
can be used without tmux as well to process text files were -p
and -u
are quite useful!
That is a good point that I've missed 👍
Hi there, I noticed a bug on the pattern matching, not supporting UPPER CASE urls. Also, I found out that there was no 'sftp' prefix on the regular expression for that matter.
I wondered which other cases I may be missing and I think that it would be a good idea to have tests to see what works and what doesn't. After starting with tests I realized that I had to make several changes to the code for them to work and be easily understandable.
I hope you don't mind the many changes I made to your code, if so, please let me know and I can fix whatever you think is best.
This doesn't require any extra dependency, you can run them as (for example)
python -m tests/test_get_urls
.Here is an example output of what this PR adds:
If you want, you can use a test runner to simplify the task of running all the tests, I recommend you
pytest
, this is an output using it:Changes list:
re.I