Skip to content

Conversation

@ntkme
Copy link
Member

@ntkme ntkme commented Oct 25, 2025

No description provided.

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.

@ntkme ntkme merged commit c1f8882 into main Oct 25, 2025
94 checks passed
@ntkme ntkme deleted the gem-package-importer branch October 25, 2025 15:36
@ntkme ntkme restored the gem-package-importer branch October 25, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants