Make asset_cache_buster return a hash with path and query, while still maintaining support for cache busting via query string if a string is returned.
This commit is contained in:
parent
21928907e4
commit
2f3b757b46
@ -138,11 +138,17 @@ module Compass::SassExtensions::Functions::Urls
|
||||
def cache_busted_path(path, real_path)
|
||||
cache_buster = compute_cache_buster(path, real_path)
|
||||
if cache_buster.nil?
|
||||
path
|
||||
elsif cache_buster =~ %r{/}
|
||||
cache_buster
|
||||
return path
|
||||
elsif cache_buster.is_a?(String)
|
||||
cache_buster = {:query => cache_buster}
|
||||
else
|
||||
"%s?%s" % [path, cache_buster]
|
||||
path = cache_buster[:path] if cache_buster[:path]
|
||||
end
|
||||
|
||||
if cache_buster[:query]
|
||||
"%s?%s" % [path, cache_buster[:query]]
|
||||
else
|
||||
path
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -11,7 +11,16 @@ line_comments = false
|
||||
|
||||
asset_cache_buster do |path, file|
|
||||
pathname = Pathname.new(path)
|
||||
"%s/%s-BUSTED%s" % [pathname.dirname, pathname.basename(pathname.extname), pathname.extname]
|
||||
|
||||
case pathname.basename(pathname.extname).to_s
|
||||
when "grid"
|
||||
new_path = "%s/%s-BUSTED%s" % [pathname.dirname, pathname.basename(pathname.extname), pathname.extname]
|
||||
{:path => new_path, :query => nil}
|
||||
when "feed"
|
||||
"query_string"
|
||||
when "dk"
|
||||
{:query => "query_string"}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
@ -3,3 +3,7 @@
|
||||
.inlinegrid { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAUEAYAAACv1qP4AAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAZ0lEQVRYw+3QwQ2AIBAFUTEUwI3+uzN7gDscsIgxEuO8An52J11X73OudfxMraXkzHfO3Y98nQEhA0IGhAwIGRAyIGRAyICQASEDQgaEDAgZEDIgZEDIgJABoZzSGK3tPuN9ERFP7Nw4fg+c5g8V1wAAAABJRU5ErkJggg=='); }
|
||||
|
||||
.no-buster { background-image: url('http://assets0.example.com/images/grid.png'); }
|
||||
|
||||
.feed { background-image: url('http://assets0.example.com/images/feed.png?query_string'); }
|
||||
|
||||
.dk { background-image: url('http://assets0.example.com/images/flags/dk.png?query_string'); }
|
||||
|
BIN
test/fixtures/stylesheets/busted_image_urls/images/feed.png
vendored
Normal file
BIN
test/fixtures/stylesheets/busted_image_urls/images/feed.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 691 B |
BIN
test/fixtures/stylesheets/busted_image_urls/images/flags/dk.png
vendored
Normal file
BIN
test/fixtures/stylesheets/busted_image_urls/images/flags/dk.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 808 B |
@ -6,3 +6,9 @@
|
||||
|
||||
.no-buster
|
||||
background-image: image-url("grid.png", $only-path: false, $cache-buster: false)
|
||||
|
||||
.feed
|
||||
background-image: image-url(unquote("feed.png"))
|
||||
|
||||
.dk
|
||||
background-image: image-url(unquote("flags/dk.png"))
|
Loading…
Reference in New Issue
Block a user