Sha256: 067bfb45aae96c6c9c5e56c7b7ec42702e5ff87331b8c4975525ebaf73a8069d

Contents?: true

Size: 498 Bytes

Versions: 4

Compression:

Stored size: 498 Bytes

Contents

# frozen_string_literal: true

require "uri"

module FidoMetadata
  module Coercer
    module EscapedURI
      # The character # is a reserved character and not allowed in URLs, it is replaced by its hex value %x23.
      # https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-metadata-service-v2.0-rd-20180702.html#idl-def-MetadataTOCPayloadEntry
      def self.coerce(value)
        return value if value.is_a?(URI)

        URI(value.gsub(/%x23/, "#")) if value
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fido_metadata-0.4.0 lib/fido_metadata/coercer/escaped_uri.rb
fido_metadata-0.3.0 lib/fido_metadata/coercer/escaped_uri.rb
fido_metadata-0.2.0 lib/fido_metadata/coercer/escaped_uri.rb
fido_metadata-0.1.0 lib/fido_metadata/coercer/escaped_uri.rb