Sha256: 3b5a5d86e8bf89e9d38f7631dab96f7a07fd058c70495a271bde4fc26dd44af3

Contents?: true

Size: 580 Bytes

Versions: 3

Compression:

Stored size: 580 Bytes

Contents

module Hyperstack
  module Router
    class Location
      include Native::Wrapper

      def initialize(native)
        @native = native
      end

      def to_n
        @native
      end

      def query
        return {} if search.blank?

        Hash[search[1..-1].split('&').map { |part|
          name, value = part.split('=')

          [`decodeURIComponent(#{name})`, `decodeURIComponent(#{value})`]
        }]
      end

      alias_native :pathname
      alias_native :search
      alias_native :hash
      alias_native :state
      alias_native :key
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hyper-router-1.0.alpha1.8 lib/hyperstack/router/location.rb
hyper-router-1.0.alpha1.7 lib/hyperstack/router/location.rb
hyper-router-1.0.alpha1.6 lib/hyperstack/router/location.rb