BigW Consortium Gitlab

Commit 466bec7c by Robert Speicher

Rename SCHEME_PATTERN to LINK_PATTERN

parent cd3c24a8
...@@ -27,9 +27,9 @@ module Gitlab ...@@ -27,9 +27,9 @@ module Gitlab
# in the generated link. # in the generated link.
# #
# Rubular: http://rubular.com/r/cxjPyZc7Sb # Rubular: http://rubular.com/r/cxjPyZc7Sb
SCHEME_PATTERN = %r{([a-z][a-z0-9\+\.-]+://\S+)(?<!,|\.)} LINK_PATTERN = %r{([a-z][a-z0-9\+\.-]+://\S+)(?<!,|\.)}
# Text matching SCHEME_PATTERN inside these elements will not be linked # Text matching LINK_PATTERN inside these elements will not be linked
IGNORE_PARENTS = %w(a code kbd pre script style).to_set IGNORE_PARENTS = %w(a code kbd pre script style).to_set
def call def call
...@@ -62,14 +62,14 @@ module Gitlab ...@@ -62,14 +62,14 @@ module Gitlab
@doc = parse_html(rinku) @doc = parse_html(rinku)
end end
# Autolinks any text matching SCHEME_PATTERN that Rinku didn't already # Autolinks any text matching LINK_PATTERN that Rinku didn't already
# replace # replace
def text_parse def text_parse
search_text_nodes(doc).each do |node| search_text_nodes(doc).each do |node|
content = node.to_html content = node.to_html
next if has_ancestor?(node, IGNORE_PARENTS) next if has_ancestor?(node, IGNORE_PARENTS)
next unless content.match(SCHEME_PATTERN) next unless content.match(LINK_PATTERN)
# If Rinku didn't link this, there's probably a good reason, so we'll # If Rinku didn't link this, there's probably a good reason, so we'll
# skip it too # skip it too
...@@ -86,7 +86,7 @@ module Gitlab ...@@ -86,7 +86,7 @@ module Gitlab
end end
def autolink_filter(text) def autolink_filter(text)
text.gsub(SCHEME_PATTERN) do |match| text.gsub(LINK_PATTERN) do |match|
options = link_options.merge(href: match) options = link_options.merge(href: match)
content_tag(:a, match, options) content_tag(:a, match, options)
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment