Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 404 for loading source maps with digests in url #194

Merged
merged 1 commit into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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