const expression = /([а-яё]+[,.]\s)?[а-яё]+\.?/i;
const cases = [
'г. Город',
'г. Город.',
'г, Город',
'г, Город.',
'Город',
'Город.'
];
for (const variant of cases) {
console.log(variant, expression.test(variant));
}
/*
'г. Город' true
'г. Город.' true
'г, Город' true
'г, Город.' true
'Город' true
'Город.' true
*/
const addedFiles = [];
const createImprint = (file) => {
const payload = [file.name, file.type, file.size, file.lastModified];
return payload.map(entry => btoa(encodeURIComponent(entry))).join('_');
};
input.addEventListener('change', event => {
const { files } = event.target;
const existingImprints = addedFiles.map(entry => entry.imprint);
for (const file of files) {
const imprint = createImprint(file);
if (!existingImprints.includes(imprint)) {
addedFiles.push({
file,
imprint
});
}
}
event.target.value = '';
});
- fetch('https://facejsonserver.000webhostapp.com/data.json')
+ fetch('https://facejsonserver.000webhostapp.com/')