-
Notifications
You must be signed in to change notification settings - Fork 4
Ignoring files by regexp
Note
This setting is dedicated to "ignore mode," meaning it works ONLY FOR OLR/OLUR systems.
More about it:
"Ignore mode"
This feature is very different from "ignoring extensions." It not only works on extensions but on entire arrays of files. It expects specific and hardcoded input to function properly. If you are unfamiliar with regexp (regular expressions), it is recommended not to touch this feature.
It uses the default RegExpConstructor
(RegExp
) built into JavaScript. It does
not send any custom flags during the testing procedure of a filename with a given
regular expression. Additionally, before applying the "mask," it attempts to parse
it from a string into the regexp (see _mask
assignment).
Here is an example of the program implementation (may differ in source):
if (this.settings.is_ignore) {
for (const mask of this.settings.ignore_masks.split(';')) {
const _mask = mask.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
try {
const regex = new RegExp(_mask);
if (regex.test(file.name)) {
return;
}
} catch (error) {
if (!this.settings.silence_errors) {
console.error(error);
} else {
console.debug(`[UNITADE-ERROR]: ERROR IS SILENCED, ERROR: ${error}`);
}
}
}
}
Important
Because ignore mode works "raw-to-raw," it can cause unexpected behavior for
the user due to spaces, trims, symbols like \n
, \t
, etc. Be careful with
your input in these settings.