Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/label.rb')
-rw-r--r--app/models/label.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/label.rb b/app/models/label.rb
index 013e6bf5978..8980049cef8 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -40,6 +40,22 @@ class Label < ActiveRecord::Base
'~'
end
+ # Pattern used to extract label references from text
+ #
+ # TODO (rspeicher): Limit to double quotes (meh) or disallow single quotes in label names (bad).
+ def self.reference_pattern
+ %r{
+ #{reference_prefix}
+ (?:
+ (?<label_id>\d+) | # Integer-based label ID, or
+ (?<label_name>
+ [A-Za-z0-9_-]+ | # String-based single-word label title
+ ['"][^&\?,]+['"] # String-based multi-word label surrounded in quotes
+ )
+ )
+ }x
+ end
+
# Returns the String necessary to reference this Label in Markdown
#
# format - Symbol format to use (default: :id, optional: :name)