feat: add excludeUrls and modify urls in WebRequestFilter for better URL filtering (#44692)
* feat: add excludeUrls to web request filter * refactor: add deprecated field * test: update tests * lint: newline * docs: improve API doc * fix: add is filter defined property to match all urls * refactor: remove includeUrls * refactor: remove typescript binding * refactor: all_url * refactor: remove isDefined methods * refactor: remove comment * fix: logic * docs: add to breaking changes
This commit is contained in:
parent
7dfcec931a
commit
02be7c1185
6 changed files with 150 additions and 32 deletions
|
@ -1,4 +1,5 @@
|
|||
# WebRequestFilter Object
|
||||
|
||||
* `urls` string[] - Array of [URL patterns](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns) that will be used to filter out the requests that do not match the URL patterns.
|
||||
* `types` String[] (optional) - Array of types that will be used to filter out the requests that do not match the types. When not specified, all types will be matched. Can be `mainFrame`, `subFrame`, `stylesheet`, `script`, `image`, `font`, `object`, `xhr`, `ping`, `cspReport`, `media` or `webSocket`.
|
||||
* `urls` string[] - Array of [URL patterns](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns) used to include requests that match these patterns. Use the pattern `<all_urls>` to match all URLs.
|
||||
* `excludeUrls` string[] (optional) - Array of [URL patterns](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns) used to exclude requests that match these patterns.
|
||||
* `types` string[] (optional) - Array of types that will be used to filter out the requests that do not match the types. When not specified, all types will be matched. Can be `mainFrame`, `subFrame`, `stylesheet`, `script`, `image`, `font`, `object`, `xhr`, `ping`, `cspReport`, `media` or `webSocket`.
|
||||
|
|
|
@ -73,6 +73,7 @@ The `callback` has to be called with an `response` object.
|
|||
Some examples of valid `urls`:
|
||||
|
||||
```js
|
||||
'<all_urls>'
|
||||
'http://foo:1234/'
|
||||
'http://foo.com/'
|
||||
'http://foo:1234/bar'
|
||||
|
|
|
@ -63,6 +63,22 @@ webContents.on('console-message', ({ level, message, lineNumber, sourceId, frame
|
|||
|
||||
Additionally, `level` is now a string with possible values of `info`, `warning`, `error`, and `debug`.
|
||||
|
||||
### Behavior Changed: `urls` property of `WebRequestFilter`.
|
||||
|
||||
Previously, an empty urls array was interpreted as including all URLs. To explicitly include all URLs, developers should now use the `<all_urls>` pattern, which is a [designated URL pattern](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns#all_urls) that matches every possible URL. This change clarifies the intent and ensures more predictable behavior.
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
const deprecatedFilter = {
|
||||
urls: []
|
||||
}
|
||||
|
||||
// Replace with
|
||||
const newFilter = {
|
||||
urls: ['<all_urls>']
|
||||
}
|
||||
```
|
||||
|
||||
### Deprecated: `systemPreferences.isAeroGlassEnabled()`
|
||||
|
||||
The `systemPreferences.isAeroGlassEnabled()` function has been deprecated without replacement.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue