From 77721cc773f68aa4bfc86f2cc319b87557cff675 Mon Sep 17 00:00:00 2001 From: Daniel Koza Date: Fri, 5 Jun 2020 15:12:27 +0200 Subject: [PATCH 1/3] check if subpath exists to get rid off '.rvm/gems/ruby-2.7.0/gems/sprockets-4.0.1/lib/sprockets/path_utils.rb:165:in : undefined method for nil:NilClass (NoMethodError)' error --- lib/sprockets/path_utils.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sprockets/path_utils.rb b/lib/sprockets/path_utils.rb index c4d37ba75..488794506 100644 --- a/lib/sprockets/path_utils.rb +++ b/lib/sprockets/path_utils.rb @@ -162,7 +162,7 @@ def set_pipeline(path, mime_exts, pipeline_exts, pipeline) def split_subpath(path, subpath) return "" if path == subpath path = File.join(path, ''.freeze) - if subpath.start_with?(path) + if subpath and subpath.start_with?(path) subpath[path.length..-1] else nil From bc8c042757da927f42f40d1f3059da7a0151bf62 Mon Sep 17 00:00:00 2001 From: Daniel Koza Date: Mon, 8 Jun 2020 15:57:55 +0200 Subject: [PATCH 2/3] add test --- test/test_path_utils.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_path_utils.rb b/test/test_path_utils.rb index 669a85a04..59a2490a8 100644 --- a/test/test_path_utils.rb +++ b/test/test_path_utils.rb @@ -109,6 +109,8 @@ def test_split_subpath_from_root_path subpath = File.expand_path("../fixtures/default/app/application.js", __FILE__) assert_equal "app/application.js", split_subpath(path, subpath) + assert_equal nil, split_subpath(path, nil) + subpath = File.expand_path("../fixtures/default", __FILE__) assert_equal "", split_subpath(path, subpath) From b8523b35d2e9c317eb84bcbdda31e6e758f096ff Mon Sep 17 00:00:00 2001 From: Daniel Koza Date: Tue, 9 Jun 2020 08:25:50 +0200 Subject: [PATCH 3/3] Use shortcut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rafael França --- lib/sprockets/path_utils.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sprockets/path_utils.rb b/lib/sprockets/path_utils.rb index 488794506..d46f201a5 100644 --- a/lib/sprockets/path_utils.rb +++ b/lib/sprockets/path_utils.rb @@ -162,7 +162,7 @@ def set_pipeline(path, mime_exts, pipeline_exts, pipeline) def split_subpath(path, subpath) return "" if path == subpath path = File.join(path, ''.freeze) - if subpath and subpath.start_with?(path) + if subpath&.start_with?(path) subpath[path.length..-1] else nil