Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid off undefined method `start_with?' for nil:NilClass error #684

Merged
merged 3 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 and subpath.start_with?(path)
dakolech marked this conversation as resolved.
Show resolved Hide resolved
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