Skip to content
Open
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
7 changes: 4 additions & 3 deletions lib/propshaft/compiler/source_mapping_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ def compile(asset, input)

private
def asset_path(source_mapping_url, logical_path)
source_mapping_url.gsub!(/^(.+\/)?#{url_prefix}\//, "")
source_mapping_url.gsub!(/^(.+\/)?#{url_prefix}\//, "/")
source_mapping_path = Pathname.new(source_mapping_url)

if logical_path.dirname.to_s == "."
source_mapping_url
if source_mapping_path.absolute?
source_mapping_url.sub(/^\//, "")
else
logical_path.dirname.join(source_mapping_url).to_s
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var fun; //# sourceMappingURL=/assets/nested/sourceMappingURL-already-prefixed-nested-with-subdirectory.js.map
Original file line number Diff line number Diff line change
@@ -1 +1 @@
var fun; //# sourceMappingURL=/assets/sourceMappingURL-already-prefixed-nested.js.map
var fun; //# sourceMappingURL=/assets/nested/sourceMappingURL-already-prefixed-nested.js.map
2 changes: 2 additions & 0 deletions test/propshaft/compiler/source_mapping_urls_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class Propshaft::Compiler::SourceMappingUrlsTest < ActiveSupport::TestCase
compile_asset(find_asset("sourceMappingURL-already-prefixed.js", fixture_path: "mapped"))
assert_match %r{//# sourceMappingURL=/assets/nested/sourceMappingURL-already-prefixed-nested-[a-z0-9]{8}\.js\.map},
compile_asset(find_asset("nested/sourceMappingURL-already-prefixed-nested.js", fixture_path: "mapped"))
assert_match %r{//# sourceMappingURL=/assets/nested/sourceMappingURL-already-prefixed-nested-with-subdirectory-[a-z0-9]{8}\.js\.map},
compile_asset(find_asset("nested/sourceMappingURL-already-prefixed-nested-with-subdirectory.js", fixture_path: "mapped"))
end

test "sourceMapURL is already prefixed with an incorrect url_prefix" do
Expand Down