gitlab-org--gitlab-foss/lib/constraints/namespace_url_constrainer.rb
Dmitriy Zaporozhets 6b90ccb9fd Change user & group landing page routing from /u/:name & /groups/:name to /:name
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-10-06 19:50:48 +03:00

13 lines
277 B
Ruby

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