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

Keep this gem available with Ruby 3.1 #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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/data_uri/uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ def self.build(arg)
end
end

@@schemes['DATA'] = Data
scheme_list['DATA'] = Data

Choose a reason for hiding this comment

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

Perhaps this new improvement could also be used?
ruby/uri@4346daa

Copy link

@olleolleolle olleolleolle Aug 4, 2022

Choose a reason for hiding this comment

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

I made a Rails initializer with this content, which worked for me:

require 'data_uri'
require 'data_uri/open_uri'

URI.register_scheme('DATA', URI::Data)

Copy link

@haseebeqx haseebeqx Jan 9, 2023

Choose a reason for hiding this comment

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

I recommend to do this to make it available for older versions of ruby. also used https://ruby-doc.org/stdlib-3.1.0/libdoc/uri/rdoc/URI.html#method-c-register_scheme

unless defined?(self.register_scheme)
  def self.register_scheme(scheme, klass)
     @@schemes[scheme] = klass
  end
end
register_scheme 'DATA', Data


end