Skip to content

Commit

Permalink
update logic to handle index in a filename like app/controllers/utili…
Browse files Browse the repository at this point in the history
…ties/sha256_index.js
  • Loading branch information
mylons committed Jan 3, 2024
1 parent a4d915b commit c5cb32b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/importmap/map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,14 @@ def expand_directories_into(paths)
end

def module_name_from(filename, mapping)
[ mapping.under, filename.to_s.remove(filename.extname).remove(/\/?index$/).presence ].compact.join("/")
[
mapping.under,
if filename.to_s == 'index.js'
''
else
filename.to_s.remove(filename.extname).remove(/\/index$/) # Original logic
end.presence
].compact.join("/")
end

def module_path_from(filename, mapping)
Expand Down

0 comments on commit c5cb32b

Please sign in to comment.