sprockets 4.2.0 → 4.2.1

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: 3c5995147a647a6d47d625b6cc9f10586506f3832cff0070985ec9560ee3fc0d
4
- data.tar.gz: 1befd6f705efbef88f05dc58b38f719f11b445f76c60a95f854a43ef8e84c21d
3
+ metadata.gz: 543299a5bdbb4620f7e14c346728230740474c835519d22f1c31f76110588912
4
+ data.tar.gz: d22cfead2059a729f6e67c990d7fa606f9cf56f9060941bea1ed977bf7fe59f3
5
5
  SHA512:
6
- metadata.gz: 9d47aea08307515c8a0fab29615fbde5f892c91300668afd83b2739032adeb77794d4303e6ecb56c570bc784695d25304f7481fa45c4ab7bbe0727281ee7deab
7
- data.tar.gz: 6d0f0b116766053d96402f5d88602374829ef9610160bd8398a093db33ceaafe31a2f2b33a8d0c615769f0bbba7c39d867db90dfded9bc5ff35d0c0ff4482e36
6
+ metadata.gz: 7e0b291f575acdf547fa11e803858f561e38ce57ef76734ce04cc2fce6cfca6516fa2f7b8c5d2390f1ff5400e1e72885c7741b4dc7f28f0956b4aad3a617eec2
7
+ data.tar.gz: 53e8bab09fdc3dcbd113fa33c4d29bf764ca7d1b11b176ed83d6818d6c7a822cca848f18d5ad7d1dea51e5d015a4cc53bd00e456506a8060f7ad2dbd7fd10af9
data/CHANGELOG.md CHANGED
@@ -2,12 +2,23 @@
2
2
 
3
3
  Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprockets/blob/master/UPGRADING.md
4
4
 
5
+ ## 4.2.1
6
+
7
+ - Fix for precompile issues when multiple extensions map to the same MIME type (eg. `.jpeg` / `.jpg`). [#781](https://github.com/rails/sprockets/pull/781)
8
+ - Fix `application/css-sourcemap+json` charset [#764](https://github.com/rails/sprockets/pull/764)
9
+ - Fix compatibility with Rack 2 applications. [#790](https://github.com/rails/sprockets/pull/790)
10
+
5
11
  ## 4.2.0
6
12
 
7
13
  - Rack 3 compatibility. [#758](https://github.com/rails/sprockets/pull/758)
8
14
  - Fix thread safety of `Sprockets::CachedEnvironment` and `Sprockets::Cache::MemoryStore`. [#771](https://github.com/rails/sprockets/pull/771)
9
15
  - Add support for Rack 3.0. Headers set by sprockets will now be lower case. [#758](https://github.com/rails/sprockets/pull/758)
10
16
  - Make `Sprockets::Utils.module_include` thread safe on JRuby. [#759](https://github.com/rails/sprockets/pull/759)
17
+ - Fix typo in `asset.rb` file. [#768](https://github.com/rails/sprockets/pull/768)
18
+
19
+ ## 4.1.1
20
+
21
+ - Fix `Sprockets::Server` to return response headers to be compatible with Rack::Lint 2.0.
11
22
 
12
23
  ## 4.1.0
13
24
 
@@ -137,7 +137,7 @@ module Sprockets
137
137
  DigestUtils.pack_hexdigest(digest)
138
138
  end
139
139
 
140
- # Pubic: ETag String of Asset.
140
+ # Public: ETag String of Asset.
141
141
  def etag
142
142
  version = environment_version
143
143
 
@@ -165,7 +165,9 @@ module Sprockets
165
165
  end
166
166
 
167
167
  if type = unloaded.params[:type]
168
- logical_path += config[:mime_types][type][:extensions].first
168
+ extensions = config[:mime_types][type][:extensions]
169
+ extension = extensions.include?(extname) ? extname : extensions.first
170
+ logical_path += extension
169
171
  end
170
172
 
171
173
  if type != file_type && !config[:transformers][file_type][type]
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require 'set'
3
3
  require 'time'
4
- require 'rack/utils'
4
+ require 'rack'
5
5
 
6
6
  module Sprockets
7
7
  # `Server` is a concern mixed into `Environment` and
@@ -11,6 +11,16 @@ module Sprockets
11
11
  # Supported HTTP request methods.
12
12
  ALLOWED_REQUEST_METHODS = ['GET', 'HEAD'].to_set.freeze
13
13
 
14
+ # :stopdoc:
15
+ if Gem::Version.new(Rack::RELEASE) < Gem::Version.new("3")
16
+ X_CASCADE = "X-Cascade"
17
+ VARY = "Vary"
18
+ else
19
+ X_CASCADE = "x-cascade"
20
+ VARY = "vary"
21
+ end
22
+ # :startdoc:
23
+
14
24
  # `call` implements the Rack 1.x specification which accepts an
15
25
  # `env` Hash and returns a three item tuple with the status code,
16
26
  # headers, and body.
@@ -148,39 +158,39 @@ module Sprockets
148
158
  # Returns a 400 Forbidden response tuple
149
159
  def bad_request_response(env)
150
160
  if head_request?(env)
151
- [ 400, { "content-type" => "text/plain", "content-length" => "0" }, [] ]
161
+ [ 400, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "0" }, [] ]
152
162
  else
153
- [ 400, { "content-type" => "text/plain", "content-length" => "11" }, [ "Bad Request" ] ]
163
+ [ 400, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "11" }, [ "Bad Request" ] ]
154
164
  end
155
165
  end
156
166
 
157
167
  # Returns a 403 Forbidden response tuple
158
168
  def forbidden_response(env)
159
169
  if head_request?(env)
160
- [ 403, { "content-type" => "text/plain", "content-length" => "0" }, [] ]
170
+ [ 403, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "0" }, [] ]
161
171
  else
162
- [ 403, { "content-type" => "text/plain", "content-length" => "9" }, [ "Forbidden" ] ]
172
+ [ 403, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "9" }, [ "Forbidden" ] ]
163
173
  end
164
174
  end
165
175
 
166
176
  # Returns a 404 Not Found response tuple
167
177
  def not_found_response(env)
168
178
  if head_request?(env)
169
- [ 404, { "content-type" => "text/plain", "content-length" => "0", "x-cascade" => "pass" }, [] ]
179
+ [ 404, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "0", X_CASCADE => "pass" }, [] ]
170
180
  else
171
- [ 404, { "content-type" => "text/plain", "content-length" => "9", "x-cascade" => "pass" }, [ "Not found" ] ]
181
+ [ 404, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "9", X_CASCADE => "pass" }, [ "Not found" ] ]
172
182
  end
173
183
  end
174
184
 
175
185
  def method_not_allowed_response
176
- [ 405, { "content-type" => "text/plain", "content-length" => "18" }, [ "Method Not Allowed" ] ]
186
+ [ 405, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "18" }, [ "Method Not Allowed" ] ]
177
187
  end
178
188
 
179
189
  def precondition_failed_response(env)
180
190
  if head_request?(env)
181
- [ 412, { "content-type" => "text/plain", "content-length" => "0", "x-cascade" => "pass" }, [] ]
191
+ [ 412, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "0", X_CASCADE => "pass" }, [] ]
182
192
  else
183
- [ 412, { "content-type" => "text/plain", "content-length" => "19", "x-cascade" => "pass" }, [ "Precondition Failed" ] ]
193
+ [ 412, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "19", X_CASCADE => "pass" }, [ "Precondition Failed" ] ]
184
194
  end
185
195
  end
186
196
 
@@ -189,7 +199,7 @@ module Sprockets
189
199
  def javascript_exception_response(exception)
190
200
  err = "#{exception.class.name}: #{exception.message}\n (in #{exception.backtrace[0]})"
191
201
  body = "throw Error(#{err.inspect})"
192
- [ 200, { "content-type" => "application/javascript", "content-length" => body.bytesize.to_s }, [ body ] ]
202
+ [ 200, { Rack::CONTENT_TYPE => "application/javascript", Rack::CONTENT_LENGTH => body.bytesize.to_s }, [ body ] ]
193
203
  end
194
204
 
195
205
  # Returns a CSS response that hides all elements on the page and
@@ -242,7 +252,7 @@ module Sprockets
242
252
  }
243
253
  CSS
244
254
 
245
- [ 200, { "content-type" => "text/css; charset=utf-8", "content-length" => body.bytesize.to_s }, [ body ] ]
255
+ [ 200, { Rack::CONTENT_TYPE => "text/css; charset=utf-8", Rack::CONTENT_LENGTH => body.bytesize.to_s }, [ body ] ]
246
256
  end
247
257
 
248
258
  # Escape special characters for use inside a CSS content("...") string
@@ -258,18 +268,18 @@ module Sprockets
258
268
  headers = {}
259
269
 
260
270
  # Set caching headers
261
- headers["cache-control"] = +"public"
262
- headers["etag"] = %("#{etag}")
271
+ headers[Rack::CACHE_CONTROL] = +"public"
272
+ headers[Rack::ETAG] = %("#{etag}")
263
273
 
264
274
  # If the request url contains a fingerprint, set a long
265
275
  # expires on the response
266
276
  if path_fingerprint(env["PATH_INFO"])
267
- headers["cache-control"] << ", max-age=31536000, immutable"
277
+ headers[Rack::CACHE_CONTROL] << ", max-age=31536000, immutable"
268
278
 
269
279
  # Otherwise set `must-revalidate` since the asset could be modified.
270
280
  else
271
- headers["cache-control"] << ", must-revalidate"
272
- headers["vary"] = "Accept-Encoding"
281
+ headers[Rack::CACHE_CONTROL] << ", must-revalidate"
282
+ headers[VARY] = "Accept-Encoding"
273
283
  end
274
284
 
275
285
  headers
@@ -279,7 +289,7 @@ module Sprockets
279
289
  headers = {}
280
290
 
281
291
  # Set content length header
282
- headers["content-length"] = length.to_s
292
+ headers[Rack::CONTENT_LENGTH] = length.to_s
283
293
 
284
294
  # Set content type header
285
295
  if type = asset.content_type
@@ -287,7 +297,7 @@ module Sprockets
287
297
  if type.start_with?("text/") && asset.charset
288
298
  type += "; charset=#{asset.charset}"
289
299
  end
290
- headers["content-type"] = type
300
+ headers[Rack::CONTENT_TYPE] = type
291
301
  end
292
302
 
293
303
  headers.merge(cache_headers(env, asset.etag))
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Sprockets
3
- VERSION = "4.2.0"
3
+ VERSION = "4.2.1"
4
4
  end
data/lib/sprockets.rb CHANGED
@@ -91,7 +91,7 @@ module Sprockets
91
91
 
92
92
  require 'sprockets/source_map_processor'
93
93
  register_mime_type 'application/js-sourcemap+json', extensions: ['.js.map'], charset: :unicode
94
- register_mime_type 'application/css-sourcemap+json', extensions: ['.css.map']
94
+ register_mime_type 'application/css-sourcemap+json', extensions: ['.css.map'], charset: :unicode
95
95
  register_transformer 'application/javascript', 'application/js-sourcemap+json', SourceMapProcessor
96
96
  register_transformer 'text/css', 'application/css-sourcemap+json', SourceMapProcessor
97
97
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
8
8
  - Joshua Peek
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-12-20 00:00:00.000000000 Z
12
+ date: 2023-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -423,7 +423,7 @@ homepage: https://github.com/rails/sprockets
423
423
  licenses:
424
424
  - MIT
425
425
  metadata: {}
426
- post_install_message:
426
+ post_install_message:
427
427
  rdoc_options: []
428
428
  require_paths:
429
429
  - lib
@@ -438,8 +438,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
438
438
  - !ruby/object:Gem::Version
439
439
  version: '0'
440
440
  requirements: []
441
- rubygems_version: 3.3.7
442
- signing_key:
441
+ rubygems_version: 3.4.10
442
+ signing_key:
443
443
  specification_version: 4
444
444
  summary: Rack-based asset packaging system
445
445
  test_files: []