Method: BrowserMob::Proxy::Client#whitelist

Defined in:
lib/browsermob/proxy/client.rb

#whitelist(regexp, status_code) ⇒ Object

Set a list of URL regexes to whitelist

Note that passed regexp/string should match string as a whole (i.e. if /example.com/ is whitelisted “www.example.com” won’t be allowed though if /.+example.com“ is whitelisted ”www.example.com“ will be allowed)

Parameters:

  • regexp (Regexp, String, Array<String, Regexp>)

    a regexp, string or an array of regexps/strings that urls should match to

  • status_code (Integer)

    the HTTP status code to return for URLs that do not match the whitelist



91
92
93
94
# File 'lib/browsermob/proxy/client.rb', line 91

def whitelist(regexp, status_code)
  regex = Array(regexp).map { |rx| Regexp === rx ? rx.source : rx.to_s }.join(',')
  @resource['whitelist'].put :regex => regex, :status => status_code
end