Class: Playwright::UrlMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/playwright/url_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, base_url:) ⇒ UrlMatcher

Returns a new instance of UrlMatcher.

Parameters:

  • url (String|Regexp)
  • base_url (String|nil)


5
6
7
8
# File 'lib/playwright/url_matcher.rb', line 5

def initialize(url, base_url:)
  @url = url
  @base_url = base_url
end

Instance Method Details

#match?(target_url) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
# File 'lib/playwright/url_matcher.rb', line 10

def match?(target_url)
  case @url
  when String
    joined_url == target_url || File.fnmatch?(@url, target_url)
  when Regexp
    @url.match?(target_url)
  else
    false
  end
end