Skip to content

Commit

Permalink
Digest the environment and digest before packing the hexdigest
Browse files Browse the repository at this point in the history
Closes #683
Closes #682
  • Loading branch information
rafaelfranca committed Jun 5, 2020
1 parent 841ddbe commit b698a1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/sprockets/asset.rb
Expand Up @@ -135,7 +135,7 @@ def hexdigest

# Pubic: ETag String of Asset.
def etag
DigestUtils.pack_hexdigest(environment_version + digest)
DigestUtils.hexdigest(environment_version.to_s + digest)
end

# Public: Returns String base64 digest of source.
Expand Down
12 changes: 11 additions & 1 deletion test/test_environment.rb
Expand Up @@ -735,7 +735,17 @@ def setup
test "changing version changes the etag of the asset" do
old_asset_etag = @env["gallery.js"].etag
@env.version = 'v2'
refute_equal old_asset_etag, @env["gallery.js"].etag
new_asset_etag = @env["gallery.js"].etag
refute_equal old_asset_etag, new_asset_etag
assert_equal old_asset_etag.size, new_asset_etag.size
end

test "changing version to nil does not break etag" do
old_asset_etag = @env["gallery.js"].etag
@env.version = nil
new_asset_etag = @env["gallery.js"].etag
assert_equal old_asset_etag, new_asset_etag
assert_equal old_asset_etag.size, new_asset_etag.size
end

test "changing version does not changes the digest of the asset" do
Expand Down

0 comments on commit b698a1a

Please sign in to comment.