summaryrefslogtreecommitdiff
path: root/lib/constraints/group_url_constrainer.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/constraints/group_url_constrainer.rb')
-rw-r--r--lib/constraints/group_url_constrainer.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/constraints/group_url_constrainer.rb b/lib/constraints/group_url_constrainer.rb
new file mode 100644
index 00000000000..2af6e1a11c8
--- /dev/null
+++ b/lib/constraints/group_url_constrainer.rb
@@ -0,0 +1,15 @@
+require_relative 'constrainer_helper'
+
+class GroupUrlConstrainer
+ include ConstrainerHelper
+
+ def matches?(request)
+ id = extract_resource_path(request.path)
+
+ if id =~ Gitlab::Regex.namespace_regex
+ Group.find_by(path: id).present?
+ else
+ false
+ end
+ end
+end