Skip to content

Commit

Permalink
Support base64 encoded digests to account for rollup 4.x (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronjensen authored Dec 11, 2023
1 parent 51cd24c commit 6dae310
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/propshaft/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ def ==(other_asset)

private
def already_digested?
logical_path.to_s =~ /-([0-9a-zA-Z]{7,128})\.digested/
logical_path.to_s =~ /-([0-9a-zA-Z_-]{7,128})\.digested/
end
end
10 changes: 5 additions & 5 deletions test/propshaft/asset_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ class Propshaft::AssetTest < ActiveSupport::TestCase
assert find_asset("one.txt").fresh?("f2e1ec14d6856e1958083094170ca6119c529a73")
assert_not find_asset("one.txt").fresh?("e206c34fe404c8e2f25d60dd8303f61c02b8d381")

assert find_asset("file-already-abcdefVWXYZ0123456789.digested.css").fresh?(nil)
assert find_asset("file-already-abcdefVWXYZ0123456789_-.digested.css").fresh?(nil)
end

test "digested path" do
assert_equal "one-f2e1ec14d6856e1958083094170ca6119c529a73.txt",
find_asset("one.txt").digested_path.to_s

assert_equal "file-already-abcdefVWXYZ0123456789.digested.css",
find_asset("file-already-abcdefVWXYZ0123456789.digested.css").digested_path.to_s
assert_equal "file-already-abcdefVWXYZ0123456789_-.digested.css",
find_asset("file-already-abcdefVWXYZ0123456789_-.digested.css").digested_path.to_s

assert_equal "file-already-abcdefVWXYZ0123456789.digested.debug.css",
find_asset("file-already-abcdefVWXYZ0123456789.digested.debug.css").digested_path.to_s
assert_equal "file-already-abcdefVWXYZ0123456789_-.digested.debug.css",
find_asset("file-already-abcdefVWXYZ0123456789_-.digested.debug.css").digested_path.to_s

assert_equal "file-not.digested-e206c34fe404c8e2f25d60dd8303f61c02b8d381.css",
find_asset("file-not.digested.css").digested_path.to_s
Expand Down
2 changes: 1 addition & 1 deletion test/propshaft/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Propshaft::ServerTest < ActiveSupport::TestCase
end

test "serve a predigested file" do
asset = @assembly.load_path.find("file-already-abcdefVWXYZ0123456789.digested.css")
asset = @assembly.load_path.find("file-already-abcdefVWXYZ0123456789_-.digested.css")
get "/#{asset.digested_path}"
assert_equal 200, last_response.status
end
Expand Down

0 comments on commit 6dae310

Please sign in to comment.