From c5cb32b26c6a74a0e45c9d2a024cb6252887df06 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Wed, 3 Jan 2024 07:10:12 -0800 Subject: [PATCH] update logic to handle index in a filename like app/controllers/utilities/sha256_index.js --- lib/importmap/map.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/importmap/map.rb b/lib/importmap/map.rb index 6aa4f4d..8581071 100644 --- a/lib/importmap/map.rb +++ b/lib/importmap/map.rb @@ -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)