Commit f258c46a authored by Robert Speicher's avatar Robert Speicher

Merge branch 'kc-external-url-underscore' into 'master'

Use RFC3986_PARSER when creating a new URI

See merge request gitlab-org/gitlab!59847
parents 8f03b25c 10a46510
...@@ -23,10 +23,10 @@ module API ...@@ -23,10 +23,10 @@ module API
# Using a blank component at the beginning of the join we ensure # Using a blank component at the beginning of the join we ensure
# that the resulted path will start with '/'. If the resulted path # that the resulted path will start with '/'. If the resulted path
# does not start with '/', URI::Generic#build will fail # does not start with '/', URI::Generic#new will fail
path_with_script_name = File.join('', [script_name, path].select(&:present?)) 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 URI::Generic.new(protocol, nil, host, port, nil, path_with_script_name, nil, nil, nil, URI::RFC3986_PARSER, true).to_s
end end
private private
......
...@@ -63,6 +63,12 @@ RSpec.describe API::Helpers::RelatedResourcesHelpers do ...@@ -63,6 +63,12 @@ RSpec.describe API::Helpers::RelatedResourcesHelpers do
is_expected.to start_with('https://') is_expected.to start_with('https://')
end end
it 'accepts the host if it contains an underscore' do
stub_default_url_options(host: 'w_ww.example.com')
is_expected.to start_with('http://w_ww.example.com/')
end
it 'accepts port to be nil' do it 'accepts port to be nil' do
stub_default_url_options(port: nil) stub_default_url_options(port: nil)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment