From 407bf21ff99dba1ebff4e6eb80f42c379ebbee17 Mon Sep 17 00:00:00 2001 From: Nurahmadie Date: Mon, 21 May 2012 03:26:32 +0700 Subject: [PATCH] Fix url match. --- lib/dtext.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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')