summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2018-05-18 12:56:14 +0200
committerFrancisco Javier López <fjlopez@gitlab.com>2018-05-18 12:56:14 +0200
commit4a38baee3a17121850b8a58eb78e900b53ab6200 (patch)
tree76a8c6abf9be338477cb9b88e0cc90ace3179834
parent239a8a6c6d47099cfb26f637738fbb1cf088faad (diff)
downloadgitlab-ce-fj-46459-fix-expose-url-when-base-url-set.tar.gz
Code review comments appliedfj-46459-fix-expose-url-when-base-url-set
-rw-r--r--lib/api/helpers/related_resources_helpers.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/api/helpers/related_resources_helpers.rb b/lib/api/helpers/related_resources_helpers.rb
index c7c11144100..a2cbed30229 100644
--- a/lib/api/helpers/related_resources_helpers.rb
+++ b/lib/api/helpers/related_resources_helpers.rb
@@ -13,12 +13,12 @@ module API
def expose_url(path)
url_options = Gitlab::Application.routes.default_url_options
- protocol, host, port, script_name = url_options.slice(:protocol, :host, :port, :script_name).values
+ protocol, host, port, script_name = url_options.values_at(:protocol, :host, :port, :script_name)
# Using a blank component at the beginning of the join we ensure
# that the resulted path will start with '/'. If the resulted path
# does not start with '/', URI::Generic#build will fail
- path_with_script_name = File.join('', [script_name, path].map(&:presence).compact)
+ path_with_script_name = File.join('', [script_name, path].select(&:present?))
URI::Generic.build(scheme: protocol, host: host, port: port, path: path_with_script_name).to_s
end