diff --git a/metadata.json b/metadata.json index 91160df..34c3e78 100644 --- a/metadata.json +++ b/metadata.json @@ -49,13 +49,11 @@ "da", "et", "fi", - "fr", "fr-be", "fr-fr", "fr-lu", "fr-mc", "fr-ch", - "de", "de-at", "de-de", "de-li", @@ -74,13 +72,11 @@ "nl", "nl-be", "pl", - "pt", "rm", "ro", "ro-mo", "sk", "sl", - "es", "es-es", "cy", "sv", @@ -88,18 +84,14 @@ "sv-sv", "en-gb", "en-ie", - "mo", "ru-mo", "eu", "ca", "co", "fo", - "fy", - "fur", "gd", "gl", "is", - "la", "no", "nb", "nn", @@ -107,11 +99,8 @@ "sc", "sb", "hsb", - "vo", "wa", - "ar", "ast", - "br", - "eo" + "br" ] } diff --git a/src/lib/config.js b/src/lib/config.js index c189af6..b7c3997 100644 --- a/src/lib/config.js +++ b/src/lib/config.js @@ -18,6 +18,7 @@ const defaultConfig = { someConsentGiven: 30, noConsentGiven: 30, }, + useGeolocationOnly: false, geoIPVendor: 'https://cmp.digitru.st/1/geoip.json', digitrustRedirectUrl: metadata.digitrustRedirectLocation, testingMode: 'normal', diff --git a/src/lib/utils.js b/src/lib/utils.js index 65fa7de..7dea89f 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -1,6 +1,7 @@ //jshint esversion: 6 import 'whatwg-fetch'; import Promise from 'promise-polyfill'; +import config from './config'; export { checkReprompt, @@ -91,6 +92,7 @@ function checkIfGDPRApplies(geoVendor, callback) { } function checkIfLanguageLocaleApplies(languages) { + if (config.useGeolocationOnly) return false; for (let i = 0; i < languages.length; i++) { if (EU_LANGUAGE_CODES.has(languages[i].toLowerCase())) { return true; diff --git a/src/lib/utils.test.js b/src/lib/utils.test.js index 2e9404d..b7f32ed 100644 --- a/src/lib/utils.test.js +++ b/src/lib/utils.test.js @@ -135,7 +135,7 @@ describe('utils', () => { }); describe('checkIfGDPRApplies', () => { - const returnValues = [ [ 'en-GB' ], ['fr-BE'], 'lt', 'en-US' ]; + const returnValues = [ [ 'en-GB' ], ['de'], ['fr-BE'], 'lt', 'en-US' ]; beforeEach(() => { window.fetch = jest.fn().mockImplementation(() => Promise.resolve({ headers: new Map([]) })); @@ -161,6 +161,16 @@ describe('utils', () => { }); }); + it('skips the language check if the config is set to use only geoIP', (done) => { + config.useGeolocationOnly = true; + checkIfGDPRApplies('url', (res) => { + expect(res).eq(false); + expect(window.fetch.mock.calls.length).to.equal(1); + config.useGeolocationOnly = false; + done(); + }); + }); + it('handles Internet Explorer navigator implementation', (done) => { checkIfGDPRApplies('url', (res) => { expect(res.applies).eq(true); @@ -171,7 +181,7 @@ describe('utils', () => { }); }); - it('fallbacks to ip resolution', (done) => { + it('falls back to IP resolution', (done) => { checkIfGDPRApplies('url', (res) => { expect(res).eq(false);