diff options
author | Douwe Maan <douwe@selenight.nl> | 2018-11-30 14:50:25 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2018-12-03 14:29:02 +0300 |
commit | eefbe9be06d88a5f9e73882c89cf5973978e167b (patch) | |
tree | 41f37aa99d916c7347550df44e54f2c3a3b10e5f | |
parent | 31a4b268bb9dc9868a7f615d9ca6c3dc7699ab28 (diff) |
Disable format determination based on path extension
-rw-r--r-- | config/initializers/action_dispatch_http_mime_negotiation.rb | 19 | ||||
-rw-r--r-- | spec/controllers/projects/blob_controller_spec.rb | 5 |
2 files changed, 24 insertions, 0 deletions
diff --git a/config/initializers/action_dispatch_http_mime_negotiation.rb b/config/initializers/action_dispatch_http_mime_negotiation.rb new file mode 100644 index 00000000000..bdf5b0babfb --- /dev/null +++ b/config/initializers/action_dispatch_http_mime_negotiation.rb @@ -0,0 +1,19 @@ +# Starting with Rails 5, Rails tries to determine the request format based on +# the extension of the full URL path if no explicit `format` param or `Accept` +# header is provided, like when simply browsing to a page in your browser. +# +# This is undesireable in GitLab, because many of our paths will end in a ref or +# blob name that can end with any extension, while these pages should still be +# presented as HTML unless otherwise specified. + +# We override `format_from_path_extension` to disable this behavior. + +module ActionDispatch + module Http + module MimeNegotiation + def format_from_path_extension + nil + end + end + end +end diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index 3c5a21c47fa..9fc6af6a045 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -35,6 +35,11 @@ describe Projects::BlobController do let(:id) { 'binary-encoding/encoding/binary-1.bin' } it { is_expected.to respond_with(:success) } end + + context "Markdown file" do + let(:id) { 'master/README.md' } + it { is_expected.to respond_with(:success) } + end end context 'with file path and JSON format' do |