1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-03 18:28:13 +01:00

allow csv field names as well

This commit is contained in:
Kyle Spearrin 2017-11-13 14:09:45 -05:00
parent 745b17fe95
commit 907247b3a7

View File

@ -725,15 +725,26 @@ export default class AutofillService {
return false; return false;
} }
fieldVal = fieldVal.replace(/(?:\r\n|\r|\n)/g, ''); fieldVal = fieldVal.trim().replace(/(?:\r\n|\r|\n)/g, '');
if (name.startsWith('regex:')) { if (name.startsWith('regex=')) {
try { try {
const regexParts = name.split(':', 2); const regexParts = name.split('=', 2);
if (regexParts.length === 2) { if (regexParts.length === 2) {
const regex = new RegExp(regexParts[1], 'i'); const regex = new RegExp(regexParts[1], 'i');
return regex.test(fieldVal); return regex.test(fieldVal);
} }
} catch (e) { } } catch (e) { }
} else if (name.startsWith('csv=')) {
const csvParts = name.split('=', 2);
if (csvParts.length === 2) {
const csvVals = csvParts[1].split(',');
for (const val of csvVals) {
if (val != null && val.trim().toLowerCase() === fieldVal.toLowerCase()) {
return true;
}
}
return false;
}
} }
return fieldVal.toLowerCase() === name; return fieldVal.toLowerCase() === name;