module Selenium::WebDriver::BiDi::UrlPattern

@api private

Public Instance Methods

format_pattern(url_patterns, pattern_type) click to toggle source
# File lib/selenium/webdriver/bidi/network/url_pattern.rb, line 32
def format_pattern(url_patterns, pattern_type)
  case pattern_type
  when :string
    to_url_string_pattern(url_patterns)
  when :url
    to_url_pattern(url_patterns)
  else
    raise ArgumentError, "Unknown pattern type: #{pattern_type}"
  end
end
to_url_pattern(*url_patterns) click to toggle source
# File lib/selenium/webdriver/bidi/network/url_pattern.rb, line 43
def to_url_pattern(*url_patterns)
  url_patterns.flatten.map do |url_pattern|
    uri = URI.parse(url_pattern)

    {
      type: 'pattern',
      protocol: uri.scheme || '',
      hostname: uri.host || '',
      port: uri.port.to_s,
      pathname: uri.path || '',
      search: uri.query || ''
    }
  end
end
to_url_string_pattern(*url_patterns) click to toggle source
# File lib/selenium/webdriver/bidi/network/url_pattern.rb, line 58
def to_url_string_pattern(*url_patterns)
  url_patterns.flatten.map do |url_pattern|
    {
      type: 'string',
      pattern: url_pattern
    }
  end
end