diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-11-14 17:55:31 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-11-23 15:08:36 +0300 |
commit | 6683fdcfb0ae4ceb368b6f5f63dde0a10a4a3e1b (patch) | |
tree | 7530562c2e0702df3e74fc8ca8288e2e3f4ef0a2 /lib/constraints/group_url_constrainer.rb | |
parent | b1b5060dbad15975184ec20a1914c7c48fc804db (diff) |
Add nested groups support to the routing
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib/constraints/group_url_constrainer.rb')
-rw-r--r-- | lib/constraints/group_url_constrainer.rb | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/constraints/group_url_constrainer.rb b/lib/constraints/group_url_constrainer.rb index 2af6e1a11c8..5711d96a586 100644 --- a/lib/constraints/group_url_constrainer.rb +++ b/lib/constraints/group_url_constrainer.rb @@ -1,15 +1,17 @@ -require_relative 'constrainer_helper' - class GroupUrlConstrainer - include ConstrainerHelper - def matches?(request) - id = extract_resource_path(request.path) + id = request.params[:id] + + return false unless valid?(id) + + Group.find_by(path: id).present? + end + + private - if id =~ Gitlab::Regex.namespace_regex - Group.find_by(path: id).present? - else - false + def valid?(id) + id.split('/').all? do |namespace| + NamespaceValidator.valid?(namespace) end end end |