Sha256: cb54bead4ebbae0f69e2e4344845315a6ce5cf6d099f572492918c27fbd65bcb
Contents?: true
Size: 767 Bytes
Versions: 5
Compression:
Stored size: 767 Bytes
Contents
# frozen_string_literal: true 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? url == "#{target.uri.path}?#{target.uri.query}" else # !is_relative? && !has_query? target.uri.path == url end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems