Module: Selenium::WebDriver::BiDi::UrlPattern Private

Defined in:
lib/selenium/webdriver/bidi/network/url_pattern.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.format_pattern(url_patterns, pattern_type) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
35
36
37
38
39
40
41
# 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) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 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) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



58
59
60
61
62
63
64
65
# 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