Module: Selenium::WebDriver::BiDi::UrlPattern
- Defined in:
- rb/lib/selenium/webdriver/bidi/network/url_pattern.rb
Class Method Summary collapse
- .format_pattern(url_patterns, pattern_type) ⇒ Object
- .to_url_pattern(*url_patterns) ⇒ Object
- .to_url_string_pattern(*url_patterns) ⇒ Object
Class Method Details
.format_pattern(url_patterns, pattern_type) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'rb/lib/selenium/webdriver/bidi/network/url_pattern.rb', line 28 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
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'rb/lib/selenium/webdriver/bidi/network/url_pattern.rb', line 39 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
54 55 56 57 58 59 60 61 |
# File 'rb/lib/selenium/webdriver/bidi/network/url_pattern.rb', line 54 def to_url_string_pattern(*url_patterns) url_patterns.flatten.map do |url_pattern| { type: 'string', pattern: url_pattern } end end |