Skip to content

Commit d6565e9

Browse files
authored
Merge pull request #185 from digi-trust/candidate
Candidate
2 parents 27dae86 + 25a1743 commit d6565e9

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

metadata.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@
4949
"da",
5050
"et",
5151
"fi",
52-
"fr",
5352
"fr-be",
5453
"fr-fr",
5554
"fr-lu",
5655
"fr-mc",
5756
"fr-ch",
58-
"de",
5957
"de-at",
6058
"de-de",
6159
"de-li",
@@ -74,44 +72,35 @@
7472
"nl",
7573
"nl-be",
7674
"pl",
77-
"pt",
7875
"rm",
7976
"ro",
8077
"ro-mo",
8178
"sk",
8279
"sl",
83-
"es",
8480
"es-es",
8581
"cy",
8682
"sv",
8783
"sv-fi",
8884
"sv-sv",
8985
"en-gb",
9086
"en-ie",
91-
"mo",
9287
"ru-mo",
9388
"eu",
9489
"ca",
9590
"co",
9691
"fo",
97-
"fy",
98-
"fur",
9992
"gd",
10093
"gl",
10194
"is",
102-
"la",
10395
"no",
10496
"nb",
10597
"nn",
10698
"oc",
10799
"sc",
108100
"sb",
109101
"hsb",
110-
"vo",
111102
"wa",
112-
"ar",
113103
"ast",
114-
"br",
115-
"eo"
104+
"br"
116105
]
117106
}

src/lib/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const defaultConfig = {
1818
someConsentGiven: 30,
1919
noConsentGiven: 30,
2020
},
21+
useGeolocationOnly: false,
2122
geoIPVendor: 'https://cmp.digitru.st/1/geoip.json',
2223
digitrustRedirectUrl: metadata.digitrustRedirectLocation,
2324
testingMode: 'normal',

src/lib/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//jshint esversion: 6
22
import 'whatwg-fetch';
33
import Promise from 'promise-polyfill';
4+
import config from './config';
45

56
export {
67
checkReprompt,
@@ -91,6 +92,7 @@ function checkIfGDPRApplies(geoVendor, callback) {
9192
}
9293

9394
function checkIfLanguageLocaleApplies(languages) {
95+
if (config.useGeolocationOnly) return false;
9496
for (let i = 0; i < languages.length; i++) {
9597
if (EU_LANGUAGE_CODES.has(languages[i].toLowerCase())) {
9698
return true;

src/lib/utils.test.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ describe('utils', () => {
135135
});
136136

137137
describe('checkIfGDPRApplies', () => {
138-
const returnValues = [ [ 'en-GB' ], ['fr-BE'], 'lt', 'en-US' ];
138+
const returnValues = [ [ 'en-GB' ], ['de'], ['fr-BE'], 'lt', 'en-US' ];
139139

140140
beforeEach(() => {
141141
window.fetch = jest.fn().mockImplementation(() => Promise.resolve({ headers: new Map([]) }));
@@ -161,6 +161,16 @@ describe('utils', () => {
161161
});
162162
});
163163

164+
it('skips the language check if the config is set to use only geoIP', (done) => {
165+
config.useGeolocationOnly = true;
166+
checkIfGDPRApplies('url', (res) => {
167+
expect(res).eq(false);
168+
expect(window.fetch.mock.calls.length).to.equal(1);
169+
config.useGeolocationOnly = false;
170+
done();
171+
});
172+
});
173+
164174
it('handles Internet Explorer navigator implementation', (done) => {
165175
checkIfGDPRApplies('url', (res) => {
166176
expect(res.applies).eq(true);
@@ -171,7 +181,7 @@ describe('utils', () => {
171181
});
172182
});
173183

174-
it('fallbacks to ip resolution', (done) => {
184+
it('falls back to IP resolution', (done) => {
175185
checkIfGDPRApplies('url', (res) => {
176186

177187
expect(res).eq(false);

0 commit comments

Comments
 (0)