Tweak isBrowserExtension()'s API

Tweak `isBrowserExtension()` to take just the `config.app` string that
it needs and not the entire `config` object as argument. This is
necessary for `isBrowserExtension()` to be called by `settings.js`
instead of `index.js` (as I want it to be in the future) - when it's
called by `settings.js` the `config` object as a whole won't be
available (and hasn't been constructed yet).
parent 42df09b5
...@@ -25,7 +25,7 @@ function configFrom(window_) { ...@@ -25,7 +25,7 @@ function configFrom(window_) {
annotations: settings.annotations(window_.location.href), annotations: settings.annotations(window_.location.href),
}; };
if (isBrowserExtension(config)) { if (isBrowserExtension(config.app)) {
return config; return config;
} }
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
* website. * website.
* *
*/ */
function isBrowserExtension(config) { function isBrowserExtension(app) {
return !(config.app.startsWith('http://') || config.app.startsWith('https://')); return !(app.startsWith('http://') || app.startsWith('https://'));
} }
module.exports = isBrowserExtension; module.exports = isBrowserExtension;
...@@ -31,7 +31,7 @@ describe('annotator.config.isBrowserExtension', function() { ...@@ -31,7 +31,7 @@ describe('annotator.config.isBrowserExtension', function() {
}, },
].forEach(function(test) { ].forEach(function(test) {
it('returns ' + test.returns + ' for ' + test.url, function() { it('returns ' + test.returns + ' for ' + test.url, function() {
assert.equal(isBrowserExtension({app: test.url}), test.returns); assert.equal(isBrowserExtension(test.url), test.returns);
}); });
}); });
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment