lib/propshaft/server.rb in propshaft-0.7.0 vs lib/propshaft/server.rb in propshaft-0.8.0

- old
+ new

@@ -12,31 +12,37 @@ compiled_content = @assembly.compilers.compile(asset) [ 200, { - "content-length" => compiled_content.length.to_s, - "content-type" => asset.content_type.to_s, - "accept-encoding" => "vary", - "etag" => asset.digest, - "cache-control" => "public, max-age=31536000, immutable" + Rack::CONTENT_LENGTH => compiled_content.length.to_s, + Rack::CONTENT_TYPE => asset.content_type.to_s, + VARY => "Accept-Encoding", + Rack::ETAG => asset.digest, + Rack::CACHE_CONTROL => "public, max-age=31536000, immutable" }, [ compiled_content ] ] else - [ 404, { "content-type" => "text/plain", "content-length" => "9" }, [ "Not found" ] ] + [ 404, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "9" }, [ "Not found" ] ] end end def inspect self.class.inspect end private def extract_path_and_digest(env) full_path = Rack::Utils.unescape(env["PATH_INFO"].to_s.sub(/^\//, "")) - digest = full_path[/-([0-9a-zA-Z]{7,128}(?:\.digested)?)\.[^.]+\z/, 1] + digest = full_path[/-([0-9a-zA-Z]{7,128})\.(?!digested)[^.]+\z/, 1] path = digest ? full_path.sub("-#{digest}", "") : full_path [ path, digest ] + end + + if Gem::Version.new(Rack::RELEASE) < Gem::Version.new("3") + VARY = "Vary" + else + VARY = "vary" end end