Sha256: 9db40d780917658e2b83439fb46dd5d4cd7508e287f96bd87e3403297810ede3

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module Browser
  class Location
    if RUBY_ENGINE == 'opal'
      include Native::Wrapper

      alias_native :hash
      alias_native :host
      alias_native :hostname
      alias_native :href
      alias_native :origin
      alias_native :pathname
      alias_native :port
      alias_native :protocol
      alias_native :search
    else
      def initialize(location_string)
        @location = URI(location_string)
      rescue
        @location = URI('http://localhost/')
      end

      def hash
        @location.hash
      end

      def host
        @location.host
      end

      def hostname
        @location.hostname
      end

      def href
        @location.to_s
      end

      def origin
        @location.origin
      end

      def pathname
        @location.path
      end

      def port
        @location.port
      end

      def protocol
        @location.scheme
      end

      def search
        @location.query
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
isomorfeus-preact-22.9.0.rc3 lib/browser/location.rb
isomorfeus-preact-22.9.0.rc2 lib/browser/location.rb
isomorfeus-preact-22.9.0.rc1 lib/browser/location.rb