diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-10-24 13:51:17 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-10-24 13:51:17 +0300 |
commit | 672704f6389104b3d93c00a116dd4dc8ece19136 (patch) | |
tree | 9c1d02e77f0a654b214b2b8923a0ce281f258158 /lib/constraints | |
parent | 1a7ba2a5e8603222b51a9e9cf0ffcde68cf593d2 (diff) | |
download | gitlab-ce-672704f6389104b3d93c00a116dd4dc8ece19136.tar.gz |
Add relative url support to routing contrainers
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib/constraints')
-rw-r--r-- | lib/constraints/namespace_url_constrainer.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/constraints/namespace_url_constrainer.rb b/lib/constraints/namespace_url_constrainer.rb index 23920193743..91b70143f11 100644 --- a/lib/constraints/namespace_url_constrainer.rb +++ b/lib/constraints/namespace_url_constrainer.rb @@ -1,6 +1,9 @@ class NamespaceUrlConstrainer def matches?(request) - id = request.path.sub(/\A\/+/, '').split('/').first.sub(/.atom\z/, '') + id = request.path + id = id.sub(/\A#{relative_url_root}/, '') if relative_url_root + id = id.sub(/\A\/+/, '').split('/').first + id = id.sub(/.atom\z/, '') if id if id =~ Gitlab::Regex.namespace_regex find_resource(id) @@ -10,4 +13,12 @@ class NamespaceUrlConstrainer def find_resource(id) Namespace.find_by_path(id) end + + private + + def relative_url_root + if defined?(Gitlab::Application.config.relative_url_root) + Gitlab::Application.config.relative_url_root + end + end end |