Skip to content

Commit

Permalink
fix: Improve extraHeaders feature detection (#787)
Browse files Browse the repository at this point in the history
On Firefox forks the runtime.isFirefox detection was failing because the browser name
was not 'Firefox'. This lead to an error when registering webRequest listeners
as the extraHeaders option is not needed, preventing the extension from loading.

There is an extension API that can be used to detect support for this option: OnBeforeSendHeadersOptions.

This fix updates the feature detection check to explicitly look for this API. 
We also check to for the presence of OnBeforeSendHeadersOptions
as it does not exist on Edge.
  • Loading branch information
sammacbeth authored and lidel committed Oct 11, 2019
1 parent d01b2d3 commit e037f0a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion add-on/src/lib/ipfs-companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = async function init () {

function registerListeners () {
const onBeforeSendInfoSpec = ['blocking', 'requestHeaders']
if (!runtime.isFirefox) {
if (browser.webRequest.OnBeforeSendHeadersOptions && 'EXTRA_HEADERS' in browser.webRequest.OnBeforeSendHeadersOptions) {
// Chrome 72+ requires 'extraHeaders' for access to Referer header (used in cors whitelisting of webui)
onBeforeSendInfoSpec.push('extraHeaders')
}
Expand Down

0 comments on commit e037f0a

Please sign in to comment.