Sha256: 7e5c4e2f36fda15fdddebd2ea27f639d5c27db1792842526c8589bc91b229d2a

Contents?: true

Size: 442 Bytes

Versions: 12

Compression:

Stored size: 442 Bytes

Contents

require 'base64'

module Prawn::SVG::Loaders
  class Data
    REGEXP = %r[\A(?i:data):image/(png|jpeg);base64(;[a-z0-9]+)*,]

    def from_url(url)
      return if url[0..4].downcase != "data:"

      matches = url.match(REGEXP)
      if matches.nil?
        raise Prawn::SVG::UrlLoader::Error, "prawn-svg only supports base64-encoded image/png and image/jpeg data URLs"
      end

      Base64.decode64(matches.post_match)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
prawn-svg-0.29.1 lib/prawn/svg/loaders/data.rb
prawn-svg-0.29.0 lib/prawn/svg/loaders/data.rb
prawn-svg-0.28.0 lib/prawn/svg/loaders/data.rb
prawn-svg-0.27.1 lib/prawn/svg/loaders/data.rb
prawn-svg-0.27.0 lib/prawn/svg/loaders/data.rb
prawn-svg-0.26.0 lib/prawn/svg/loaders/data.rb
prawn-svg-0.25.2 lib/prawn/svg/loaders/data.rb
prawn-svg-0.25.1 lib/prawn/svg/loaders/data.rb
prawn-svg-0.25.0 lib/prawn/svg/loaders/data.rb
prawn-svg-0.24.0 lib/prawn/svg/loaders/data.rb
prawn-svg-0.23.1 lib/prawn/svg/loaders/data.rb
prawn-svg-0.23.0 lib/prawn/svg/loaders/data.rb