Skip to content

Commit

Permalink
fix comparison logic for prefix/suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
jcohenho committed Mar 11, 2022
1 parent 2eca234 commit 35d24a1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,18 @@ function findFilterMatches ({ filters, record }) {
}

const prefixFilter = filters.filter(([key]) => key == 'prefix');
const suffixFilter = filters.filter(([key]) => key == 'suffix');

if (prefixFilter.length > 1) {
throw 'More than one prefix is not allowed.';
}
const suffixFilter = filters.filter(([key]) => key == 'suffix');
if (suffixFilter.length > 1) {
throw 'More than one suffix is not allowed.';
}

let prefix = prefixFilter.length < 1 || prefixFilter[0][1] === record.s3.object.key.split('/')[0];
let suffix = suffixFilter.length < 1 || suffixFilter[0][1] === record.s3.object.key.split('.').pop();
return prefix || suffix;

return prefix && suffix;
}

function opts (pragma) {
Expand Down

0 comments on commit 35d24a1

Please sign in to comment.