Skip to content
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
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,11 +7,11 @@ class GemPackageImporter
def find_file_url(url, _canonicalize_context)
return unless url.start_with?('pkg:')

library, _, path = url[4..].partition(/[?#]/).first.partition('/')
library, _, path = url[4..].partition(/[#?]/).first.partition('/')
gem_dir = Gem::Dependency.new(library).to_spec.gem_dir
gem_dir = "/#{gem_dir}" unless gem_dir.start_with?('/')

"file://#{gem_dir.gsub(/[?#%]/, { '?' => '%3F', '#' => '%23', '%' => '%25' })}/#{path}"
"file://#{gem_dir.gsub(/[#%?\\]/, { '#' => '%23', '%' => '%25', '?' => '%3F', '\\' => '%5C' })}/#{path}"
rescue Gem::MissingSpecError
nil
end
Expand Down
14 changes: 10 additions & 4 deletions spec/sass/gem_package_importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
require 'bundler/inline'

sandbox do |dir|
bytes = if Gem.win_platform?
[*32..127] - '<>:"/\|?*'.unpack('C*')
else
(1..127)
end
parent_dir = "#{bytes.map(&:chr).join}スタイル"
dir.write({
'_test.scss' => '/* test */',
'_index.scss' => '@use "test";',
'test.gemspec' => <<~GEMSPEC
"#{parent_dir}/_test.scss" => '/* test */',
"#{parent_dir}/_index.scss" => '@use "test";',
"#{parent_dir}/test.gemspec" => <<~GEMSPEC
Gem::Specification.new do |spec|
spec.name = 'test'
spec.summary = 'test'
Expand All @@ -22,7 +28,7 @@
})

gemfile do
gem 'test', path: dir.path, require: false
gem 'test', path: dir.path(parent_dir), require: false
end

example.call
Expand Down