propshaft 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88560fd134482bd4d44518bde9a6813be01d538f16409be833e36664a3c998bc
4
- data.tar.gz: df495a737f633966e4aa8f7837400353ec2bc9166142e38a94b7d50350c2e092
3
+ metadata.gz: 0af7543452f4437073078df954e65042b511768cc9d78a4ff4087630aaf6b175
4
+ data.tar.gz: 9d3ae071b57446b1878d43746bb645a07c216bcedab845f87a12c10a370956ea
5
5
  SHA512:
6
- metadata.gz: f27ba3bd99cbbaeb643f466c8d37051a988809c1415ccdec2eff5577506eeeed8f4c772167e8afe461b349bb4b4e75aa22bedde7c256d023796929296d1c00e1
7
- data.tar.gz: 571d8052e3b16c7d779c55433d27c268f0ceb387213ca4b0220a200dc30885e15accc855075e4fbcf95ea71c887ff071bfa25caaa8330f0e9a5c87c33c10076f
6
+ metadata.gz: e7a5df6e8efe41b65f60ca3551ecfd1835ec6a0107bee39a999d9f5e99331bb0066c2dad2b9d6c1e252383112a9355c2c19db86143855a2c906875a54349bebb
7
+ data.tar.gz: aaf3ac3f1dbd6b493c340860fc97fe35e93ee4807693f92c21c1abe7952f0653489fe72f57c54368933f2fc3781d915f34ee8b1e7e0b84d72f753a632c222e1d
@@ -5,6 +5,8 @@ require "action_dispatch/http/mime_type"
5
5
  class Propshaft::Asset
6
6
  attr_reader :path, :logical_path, :load_path
7
7
 
8
+ CONTENT_TYPES_WITH_UTF8_CHARSET = [ Mime::Type.lookup("text/html"), Mime::Type.lookup("text/css") ]
9
+
8
10
  class << self
9
11
  def extract_path_and_digest(digested_path)
10
12
  digest = digested_path[/-([0-9a-zA-Z]{7,128})\.(?!digested)([^.]|.map)+\z/, 1]
@@ -27,7 +29,15 @@ class Propshaft::Asset
27
29
  end
28
30
 
29
31
  def content_type
30
- Mime::Type.lookup_by_extension(logical_path.extname.from(1))
32
+ @content_type ||= Mime::Type.lookup_by_extension(logical_path.extname.from(1))
33
+ end
34
+
35
+ def content_type_with_charset
36
+ if content_type.in? CONTENT_TYPES_WITH_UTF8_CHARSET
37
+ "#{content_type}; charset=utf-8"
38
+ else
39
+ content_type
40
+ end
31
41
  end
32
42
 
33
43
  def length
@@ -66,7 +66,7 @@ module Propshaft
66
66
  initializer "propshaft.assets_middleware", group: :all do |app|
67
67
  app.assets = Propshaft::Assembly.new(app.config.assets)
68
68
  if config.assets.server
69
- app.middleware.insert_after ::ActionDispatch::Static, Propshaft::Server, app.assets
69
+ app.middleware.insert_before ::ActionDispatch::Executor, Propshaft::Server, app.assets
70
70
  end
71
71
  end
72
72
 
@@ -23,7 +23,7 @@ class Propshaft::Server
23
23
  200,
24
24
  {
25
25
  Rack::CONTENT_LENGTH => compiled_content.length.to_s,
26
- Rack::CONTENT_TYPE => asset.content_type.to_s,
26
+ Rack::CONTENT_TYPE => asset.content_type_with_charset.to_s,
27
27
  VARY => "Accept-Encoding",
28
28
  Rack::ETAG => "\"#{asset.digest}\"",
29
29
  Rack::CACHE_CONTROL => "public, max-age=31536000, immutable"
@@ -1,3 +1,3 @@
1
1
  module Propshaft
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: propshaft
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
- rubygems_version: 3.6.7
102
+ rubygems_version: 4.0.3
103
103
  specification_version: 4
104
104
  summary: Deliver assets for Rails.
105
105
  test_files: []