Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
fix: Adding regex in case of glob doest work
Browse files Browse the repository at this point in the history
BETA
  • Loading branch information
Mara-Li committed Apr 21, 2022
1 parent afb12a4 commit bec5715
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Snippet-downloader/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class SnippetDownloaderTabs extends PluginSettingTab {

new Setting(containerEl)
.setName('Excluded Snippet')
.setDesc('Type the snippet name you want to exclude from the list, without the extension. Glob can work. Separate by comma.')
.setDesc('Type the snippet name you want to exclude from the list, without the extension. Glob and regex can work. Separate by comma.')
.addTextArea(text => text
.setPlaceholder('BadCSS I hate, badCSS*')
.setValue(this.plugin.settings.excludedSnippet)
Expand Down
10 changes: 7 additions & 3 deletions Snippet-downloader/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ export function searchExcluded(excludedSnippet: string, name: string): boolean {
if (excludedSnippet.length < 1) {
return false;
}
const excluded = excludedSnippet.split(",");
const excluded = test.split(",").map(e => {return e.trim();}).filter(x=>x.length>0)
for (const excl of excluded){
if (excl.trim() === name.replace('.css', '').trim()){
if (excl === name.replace('.css', '').trim()){
return true;
}
const regExcl = globRegex(excl.trim());
const regExcl = globRegex(excl);
if (name.match(regExcl)){
return true;
}
const regPureExcl= new RegExp(excl)
if (name.match(regPureExcl)) {
return true;
}
}
return false;
}
Expand Down

0 comments on commit bec5715

Please sign in to comment.