Skip to content

Commit

Permalink
Make digest regex less strict on .map extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
theodorton committed May 30, 2024
1 parent c14f2b4 commit e1b1d86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/propshaft/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def inspect
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)([^.]|.map)+\z/, 1]
path = digest ? full_path.sub("-#{digest}", "") : full_path

[ path, digest ]
Expand Down
6 changes: 6 additions & 0 deletions test/propshaft/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class Propshaft::ServerTest < ActiveSupport::TestCase
assert_equal 200, last_response.status
end

test "serve a sourcemap" do
asset = @assembly.load_path.find("file-is-a-sourcemap.js.map")
get "/#{asset.digested_path}"
assert_equal 200, last_response.status
end

test "not found" do
get "/not-found.js"

Expand Down

0 comments on commit e1b1d86

Please sign in to comment.