Skip to content

Commit 1258698

Browse files
authoredFeb 10, 2021
Properly look up entry in manifest when name is given with extension (#2919)
1 parent 4981d69 commit 1258698

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
 

‎lib/webpacker/manifest.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def load
9292
# When the user provides a name with a file extension, we want to try to strip it off.
9393
def manifest_name(name, pack_type)
9494
return name if File.extname(name.to_s).empty?
95-
File.basename(name, pack_type)
95+
File.basename(name, ".#{pack_type}")
9696
end
9797

9898
def manifest_type(pack_type)

‎test/manifest_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ def test_lookup_success!
2525
assert_equal Webpacker.manifest.lookup!("bootstrap.js"), "/packs/bootstrap-300631c4f0e0f9c865bc.js"
2626
end
2727

28+
def test_lookup_with_chunks_without_extension_success!
29+
assert_equal Webpacker.manifest.lookup_pack_with_chunks!("bootstrap", type: :javascript), ["/packs/bootstrap-300631c4f0e0f9c865bc.js"]
30+
end
31+
32+
def test_lookup_with_chunks_with_extension_success!
33+
assert_equal Webpacker.manifest.lookup_pack_with_chunks!("bootstrap.js", type: :javascript), ["/packs/bootstrap-300631c4f0e0f9c865bc.js"]
34+
end
35+
2836
def test_lookup_nil
2937
assert_nil Webpacker.manifest.lookup("foo.js")
3038
end

0 commit comments

Comments
 (0)
Please sign in to comment.