mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-10 07:50:29 -07:00
Replaced custom code by array.prototype.find
This commit is contained in:
parent
9a02d4b344
commit
c04dba1453
2 changed files with 9 additions and 16 deletions
|
|
@ -76,7 +76,6 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
|
|||
|
||||
const buildArrayInput = (arrayInput: unknown): string[] => String(arrayInput)?.trim().split(',') ?? [];
|
||||
|
||||
let isAMatch = false;
|
||||
const fileName = `${(args.inputs.includeFileDirectory ? `${getFileAbosluteDir(args.inputFileObj._id)}/` : '')
|
||||
+ getFileName(args.inputFileObj._id)
|
||||
}.${getContainer(args.inputFileObj._id)}`;
|
||||
|
|
@ -84,13 +83,10 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
|
|||
.map((term) => term.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&')); // https://github.com/tc39/proposal-regex-escaping
|
||||
if (args.inputs.pattern) searchCriteriasArray.push(String(args.inputs.pattern));
|
||||
|
||||
for (let i = 0; i < searchCriteriasArray.length; i++) {
|
||||
if (new RegExp(searchCriteriasArray[i]).test(fileName)) {
|
||||
isAMatch = true;
|
||||
args.jobLog(`'${fileName}' includes '${searchCriteriasArray[i]}'`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const searchCriteriaMatched = searchCriteriasArray
|
||||
.find((searchCriteria) => new RegExp(searchCriteria).test(fileName));
|
||||
const isAMatch = searchCriteriaMatched !== undefined;
|
||||
if (isAMatch) args.jobLog(`'${fileName}' includes '${searchCriteriaMatched}'`);
|
||||
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue