diff --git a/tests/unit/details.test.js b/tests/unit/details.test.js index d2138b5..c64d438 100644 --- a/tests/unit/details.test.js +++ b/tests/unit/details.test.js @@ -88,6 +88,30 @@ describe('onEntryData', () => { }); }); + test('filtered keys is case-insensitive', () => { + expect.assertions(2); + return details.onEntryData(loginElement, { MuH: 'value' }).then(() => { + expect(document.getElementsByClassName('detail-key').length).toBe(0); + expect(document.getElementsByClassName('detail-clickable-value').length).toBe(0); + }); + }); + + test('filtered keys always hides "password"', () => { + expect.assertions(2); + return details.onEntryData(loginElement, { password: 'value' }).then(() => { + expect(document.getElementsByClassName('detail-key').length).toBe(0); + expect(document.getElementsByClassName('detail-clickable-value').length).toBe(0); + }); + }); + + test('filtered keys always hides "Password"', () => { + expect.assertions(2); + return details.onEntryData(loginElement, { Password: 'value' }).then(() => { + expect(document.getElementsByClassName('detail-key').length).toBe(0); + expect(document.getElementsByClassName('detail-clickable-value').length).toBe(0); + }); + }); + test('url values', () => { expect.assertions(2); return details.onEntryData(loginElement, { hallo: 'https://hallo.welt' }).then(() => { diff --git a/web-extension/details.js b/web-extension/details.js index bb4a99d..32900a1 100644 --- a/web-extension/details.js +++ b/web-extension/details.js @@ -27,8 +27,10 @@ function _insertAfter(newNode, referenceNode) { } function _excludeKey(key, settings) { - const omit = settings.omitkeys.split(',').map(item => item.trim()); - return omit.some(value => value === key); + const _canonicalize = k => k.trim().toLowerCase(); + const omit = settings.omitkeys.split(','); + omit.push('password'); // Always exclude default "password/Password" key from detail view, user can use copy button + return omit.some(value => _canonicalize(value) === _canonicalize(key)); } function _detailViewFromMessage(message, settings) {