Sha256: 350d9f8ca59f1e838db104574ab2072dd664517fd60d978ab9a603f4a2daffbe

Contents?: true

Size: 431 Bytes

Versions: 1

Compression:

Stored size: 431 Bytes

Contents

require "uri"

module PAC
  require "pac/functions"

  class File
    attr_reader :source, :context

    def initialize(source)
      @source = source.dup.freeze
      @context = PAC.runtime.compile(@source)
      @context.include Functions
    end

    def find(url)
      uri = URI.parse(url)
      raise ArgumentError, "url is missing host" unless uri.host
      context.call("FindProxyForURL", url, uri.host)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pac-1.0.0 lib/pac/file.rb