diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-10-06 15:14:24 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-10-06 19:50:48 +0300 |
commit | 6b90ccb9fd57401912e1978cbad28cc693a2e0a1 (patch) | |
tree | 9e540eb6676f1d870d9e1276206f06d4fed10b48 /lib/constraints | |
parent | 7c8c80880995e0bce822a6809fe514ce0f3fda36 (diff) | |
download | gitlab-ce-6b90ccb9fd57401912e1978cbad28cc693a2e0a1.tar.gz |
Change user & group landing page routing from /u/:name & /groups/:name to /:name
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib/constraints')
-rw-r--r-- | lib/constraints/group_url_constrainer.rb | 7 | ||||
-rw-r--r-- | lib/constraints/namespace_url_constrainer.rb | 13 | ||||
-rw-r--r-- | lib/constraints/user_url_constrainer.rb | 7 |
3 files changed, 27 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..ca39b1961ae --- /dev/null +++ b/lib/constraints/group_url_constrainer.rb @@ -0,0 +1,7 @@ +require 'constraints/namespace_url_constrainer' + +class GroupUrlConstrainer < NamespaceUrlConstrainer + def find_resource(id) + Group.find_by_path(id) + end +end diff --git a/lib/constraints/namespace_url_constrainer.rb b/lib/constraints/namespace_url_constrainer.rb new file mode 100644 index 00000000000..23920193743 --- /dev/null +++ b/lib/constraints/namespace_url_constrainer.rb @@ -0,0 +1,13 @@ +class NamespaceUrlConstrainer + def matches?(request) + id = request.path.sub(/\A\/+/, '').split('/').first.sub(/.atom\z/, '') + + if id =~ Gitlab::Regex.namespace_regex + find_resource(id) + end + end + + def find_resource(id) + Namespace.find_by_path(id) + end +end diff --git a/lib/constraints/user_url_constrainer.rb b/lib/constraints/user_url_constrainer.rb new file mode 100644 index 00000000000..ef38d47d5c6 --- /dev/null +++ b/lib/constraints/user_url_constrainer.rb @@ -0,0 +1,7 @@ +require 'constraints/namespace_url_constrainer' + +class UserUrlConstrainer < NamespaceUrlConstrainer + def find_resource(id) + User.find_by_username(id) + end +end |