diff options
Diffstat (limited to 'lib/gitlab/markdown/user_reference_filter.rb')
-rw-r--r-- | lib/gitlab/markdown/user_reference_filter.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/gitlab/markdown/user_reference_filter.rb b/lib/gitlab/markdown/user_reference_filter.rb index 28ec041b1d4..c9972957182 100644 --- a/lib/gitlab/markdown/user_reference_filter.rb +++ b/lib/gitlab/markdown/user_reference_filter.rb @@ -16,16 +16,13 @@ module Gitlab # # Returns a String replaced with the return of the block. def self.references_in(text) - text.gsub(USER_PATTERN) do |match| + text.gsub(User.reference_pattern) do |match| yield match, $~[:user] end end - # Pattern used to extract `@user` user references from text - USER_PATTERN = /@(?<user>#{Gitlab::Regex::NAMESPACE_REGEX_STR})/ - def call - replace_text_nodes_matching(USER_PATTERN) do |content| + replace_text_nodes_matching(User.reference_pattern) do |content| user_link_filter(content) end end @@ -68,7 +65,8 @@ module Gitlab url = urls.namespace_project_url(project.namespace, project, only_path: context[:only_path]) - %(<a href="#{url}" class="#{link_class}">@all</a>) + text = User.reference_prefix + 'all' + %(<a href="#{url}" class="#{link_class}">#{text}</a>) end def link_to_namespace(namespace) @@ -86,7 +84,8 @@ module Gitlab url = urls.group_url(group, only_path: context[:only_path]) - %(<a href="#{url}" class="#{link_class}">@#{group}</a>) + text = Group.reference_prefix + group + %(<a href="#{url}" class="#{link_class}">#{text}</a>) end def link_to_user(user, namespace) @@ -94,7 +93,8 @@ module Gitlab url = urls.user_url(user, only_path: context[:only_path]) - %(<a href="#{url}" class="#{link_class}">@#{user}</a>) + text = User.reference_prefix + user + %(<a href="#{url}" class="#{link_class}">#{text}</a>) end def user_can_reference_group?(group) |