From 90ef3268369a0041e17c54113b7af740f8908a2d Mon Sep 17 00:00:00 2001 From: rswaminathan Date: Fri, 27 Mar 2020 00:38:36 +0400 Subject: [PATCH 1/3] Fix trailing slash issue with rails 4 --- lib/coverband/reporters/web.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coverband/reporters/web.rb b/lib/coverband/reporters/web.rb index 656f85b5..de274ab9 100644 --- a/lib/coverband/reporters/web.rb +++ b/lib/coverband/reporters/web.rb @@ -61,7 +61,7 @@ def call(env) [200, { 'Content-Type' => 'text/json' }, [debug_data]] when %r{\/load_file_details} [200, { 'Content-Type' => 'text/json' }, [load_file_details]] - when %r{\/$} + when %r{\^$} [200, { 'Content-Type' => 'text/html' }, [index]] else [404, { 'Content-Type' => 'text/html' }, ['404 error!']] From c9f6128895835921b7cb52171c4174354b182263 Mon Sep 17 00:00:00 2001 From: rswaminathan Date: Fri, 27 Mar 2020 00:43:52 +0400 Subject: [PATCH 2/3] fix rails 4 rails 4 has path_info as empty string --- lib/coverband/reporters/web.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coverband/reporters/web.rb b/lib/coverband/reporters/web.rb index de274ab9..c74ff3e4 100644 --- a/lib/coverband/reporters/web.rb +++ b/lib/coverband/reporters/web.rb @@ -61,7 +61,7 @@ def call(env) [200, { 'Content-Type' => 'text/json' }, [debug_data]] when %r{\/load_file_details} [200, { 'Content-Type' => 'text/json' }, [load_file_details]] - when %r{\^$} + when %r{\/$|^$} [200, { 'Content-Type' => 'text/html' }, [index]] else [404, { 'Content-Type' => 'text/html' }, ['404 error!']] From 04bd89ec9c1ec8cd8986d6f2e1caacf1098b7434 Mon Sep 17 00:00:00 2001 From: rswaminathan Date: Fri, 27 Mar 2020 00:53:31 +0400 Subject: [PATCH 3/3] change request.path_info Otherwise asset files don't load properly --- lib/coverband/reporters/web.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/coverband/reporters/web.rb b/lib/coverband/reporters/web.rb index c74ff3e4..5d6d918b 100644 --- a/lib/coverband/reporters/web.rb +++ b/lib/coverband/reporters/web.rb @@ -31,7 +31,8 @@ def call(env) @request = Rack::Request.new(env) return [401, { 'www-authenticate' => 'Basic realm=""' }, ['']] unless check_auth - + + request.path_info = (request.path_info == "") ? "/" : request.path_info if request.post? case request.path_info when %r{\/clear_view_tracking_file} @@ -61,7 +62,7 @@ def call(env) [200, { 'Content-Type' => 'text/json' }, [debug_data]] when %r{\/load_file_details} [200, { 'Content-Type' => 'text/json' }, [load_file_details]] - when %r{\/$|^$} + when %r{\/$} [200, { 'Content-Type' => 'text/html' }, [index]] else [404, { 'Content-Type' => 'text/html' }, ['404 error!']]