obsidian-Smart2Brain icon indicating copy to clipboard operation
obsidian-Smart2Brain copied to clipboard

Please add Chinese support for excluding files and folders

Open ZDFX opened this issue 1 year ago • 1 comments

Feature Area

Settings

Painpoint

Exclude files and folders function does not support Chinese

Describe your idea

Make excluded files and folders support Chinese paths

Alternatives

I looked at the source code and guessed that the regular expression of the following function should be causing this problem:

// src/components/Settings/FuzzModal.ts
export function wildTest(wildcard: string, str: string): boolean {
    const w = wildcard.replace(/[.+^${}()|[\]\\]/g, '\\$&'); // regexp escape
    const re = new RegExp(`\\b${w.replace(/\*/g, '.*').replace(/\?/g, '.')}`, 'i');
    return re.test(str);
}

I'm not sure how to debug the plugin, but I guess the following modifications might solve the problem:

export function wildTest(wildcard: string, str: string): boolean {
    const w = wildcard.replace(/[.+^${}()|[\]\\]/g, '\\$&'); // regexp escape
    const re = new RegExp(`\\b${w.replace(/\*/g, '.*').replace(/\?/g, '.')}`, 'iu'); // 添加 'u' 标志以支持中文
    return re.test(str);
}

Additional Context

No response

ZDFX avatar Nov 03 '24 05:11 ZDFX

@nicobrauchtgit

nicobrauchtgit avatar Jun 13 '25 19:06 nicobrauchtgit