Sha256: 968d1407f73e0eb572753e21a7ecda0355033ebf4a62a725c685a5a60d87ac0f

Contents?: true

Size: 735 Bytes

Versions: 1

Compression:

Stored size: 735 Bytes

Contents

module WhatWeb
  module Matcher
    class URL < Base
      attr_reader :url
      def initialize(target, match)
        super(target, match)
        @url = match[:url].to_s
      end

      def is_relative?
        url.match?(/^\//)
      end

      def has_query?
        url.match?(/\?/)
      end

      def match?
        if is_relative? && !has_query?
          target.uri.path.match? /#{url}$/
        elsif is_relative? && has_query?
          "#{target.uri.path}?#{target.uri.query}".match? /#{url}$/
        elsif !is_relative? && has_query?
          "#{target.uri.path}?#{target.uri.query}" == url
        else
          # !is_relative? && !has_query?
          target.uri.path == url
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_whatweb-0.1.0 lib/whatweb/matcher/url.rb