Falcion / UNITADE.md

A plugin for note-taking app Obsidian™ which allows you to treat any file extension as markdown note-file
MIT License
49 stars 0 forks source link

[BUG]: regular expressions in ignore mode bug #30

Closed Falcion closed 4 months ago

Falcion commented 5 months ago

Contact details

No response

What the essence of the bug

    at new RegExp (<anonymous>)
    at _UNITADE_PLUGIN.eval (VM212 plugin:unitade:590:17)
    at Generator.next (<anonymous>)
    at eval (VM212 plugin:unitade:73:61)
    at new Promise (<anonymous>)
    at __async (VM212 plugin:unitade:57:10)
    at eval (VM212 plugin:unitade:586:45)
    at e.tryTrigger (app.js:1:726617)
    at e.trigger (app.js:1:726550)
    at t.trigger (app.js:1:744681)

Is thrown, for this exception, just use the ignore masks module of this plugin.

Solution:

//L#35 of main.ts

if (this.settings.is_ignore) {
                for (const mask of this.settings.ignore_masks.split(';')) {
                    const escapedMask = mask.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // Escape special characters
                    console.log('Escaped Mask:', escapedMask); // Log the escaped mask
                    try {
                        const regex = new RegExp(escapedMask);
                        if (regex.test(file.name)) {
                            return;
                        }
                    } catch (error) {
                        console.error('Error creating regular expression:', error);
                    }
                }
            }

Version of an project's essence

2.0.0

On what OS you have encountered the bug.

Windows

Code of conduct

Issue policy

Falcion commented 4 months ago

Fixed in last release (v2.1.0).