Skip to content

Commit

Permalink
Merge pull request #684 from dakolech/master
Browse files Browse the repository at this point in the history
Get rid off undefined method `start_with?' for nil:NilClass error
  • Loading branch information
rafaelfranca committed Jun 23, 2022
2 parents dd961f1 + b8523b3 commit ddc411a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sprockets/path_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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&.start_with?(path)
subpath[path.length..-1]
else
nil
Expand Down
2 changes: 2 additions & 0 deletions test/test_path_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit ddc411a

Please sign in to comment.