Synthetic: Add urlpattern filtering to setHeader and addHeader commands

4th July 2023 (UTC)

The requests that the setHeader and addHeader script commands apply to can now be restricted by adding a URL pattern to the command.

For example:|

setHeader x-header-name:value https://www.speedcurve.com/* adds the header to all requests to https://www.speedcurve.com

setHeader x-header-name:value https://*.speedcurve.com/* adds the header to all requests to on SpeedCurve's subdomains e.g. https://support.speedcurve.com, https://www.speedcurve.com, https://app.speedcurve.com etc.

setHeader x-header-name:value https://www.speedcurve.com/ adds the header to just the request https://www.speedcurve.com/ and not to any other pages, sub-resources, sub-domains etc.

Previously setHeader and addHeader relied on the Chrome DevTools Protocol Network.setExtraHTTPHeaders which adds the header to all requests in a test and this could lead to CORS issues.

If a urlpattern isn't specified then a default pattern of _://_/*' is used. This replicates the previous behaviour and applies the header to all requests.

In the future we may update this default to be the domain of the page being tested.