diff --git a/lib/dtext.rb b/lib/dtext.rb index 4efc8f4d..3c69d867 100644 --- a/lib/dtext.rb +++ b/lib/dtext.rb @@ -98,11 +98,13 @@ module DText def parseurl(str) url = /(h?ttps?:\/\/\[?(:{0,2}[\w\-]+)((:{1,2}|\.)[\w\-]+)*\]?(:\d+)*(\/[^\s\n]*)*)/ - str = str.gsub(/<<\s*([^\s]+?)\s*\|\s*(.+?)\s*>>/) do + str = str.gsub(/<<\s*([^\s]+?)\s*\|\s*(.+?)\s*>>/) do |match| link = $1 name = $2 - if link =~ url + if link =~ /\A#{url}/ "#{name}" + else + match end end str = str.gsub(/(^|\s+)"(.+?)":#{url}/, '\1\2')