Skip to content
Merged
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
4 changes: 2 additions & 2 deletions lib/sass/gem_package_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class GemPackageImporter
def find_file_url(url, _canonicalize_context)
return unless url.start_with?('pkg:')

library, _, path = url[4..].partition('/')
library, _, path = url[4..].partition(/[?#]/).first.partition('/')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NodePackageImporter would throw an error complaining about querystring or hash, where GemPackageImporter would ignore them for simplicity. Users should not reply on this behavior and should avoid having querystring or hash.

gem_dir = Gem::Dependency.new(library).to_spec.gem_dir

"file://#{'/' unless gem_dir.start_with?('/')}#{gem_dir}/#{path}"
"file://#{'/' unless gem_dir.start_with?('/')}#{gem_dir.gsub(/[?#]/, { '?' => '%3F', '#' => '%23' })}/#{path}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid dragging dependency on URI, this only does the bare minimum encoding to ensure that dart side can parse the full path as expected.

rescue Gem::MissingSpecError
nil
end
Expand Down