2
0
mirror of https://github.com/moebooru/moebooru synced 2025-08-30 13:37:48 +00:00

Fix url match.

This commit is contained in:
Nurahmadie 2012-05-21 03:26:32 +07:00
parent 77f4cda49d
commit 407bf21ff9

View File

@ -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}/
"<a href=\"#{link}\">#{name}</a>"
else
match
end
end
str = str.gsub(/(^|\s+)&quot;(.+?)&quot;:#{url}/, '\1<a href="\3">\2</a>')