commit 54dd2568b988df9f0595a8d9f4f3bb71bb3835b3
parent bda9d267561218c20d26cc702b4ecbc54eea9c6a
Author: Matthieu Rakotojaona <matthieu.rakotojaona@gmail.com>
Date: Fri, 1 Jul 2016 22:44:37 +0200
use URI.extract to scan for URLs under the cursor
This code was accidentally invoking .each on the array form of
String.scan instead of using the block form. If the pattern found
multiple URLs, $& was always just the final one matched, so pressing 'g'
would just open the last URL multiple times.
Fixes #517.
Diffstat:
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/sup/modes/thread_view_mode.rb b/lib/sup/modes/thread_view_mode.rb
@@ -777,10 +777,9 @@ EOS
.map{|d| d[1].strip}.join("").strip
found = false
- (linetext || "").scan(URI::regexp).each do |matches|
+ URI.extract(linetext || "").each do |match|
begin
- link = $& # ruby magic: $& is the whole regexp match
- u = URI.parse(link)
+ u = URI.parse(match)
next unless u.absolute?
next unless ["http", "https"].include?(u.scheme)