Skip to content

Commit

Permalink
Give feedback to users with invalid regex in pattern (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleeskild authored Sep 30, 2023
1 parent 69333d5 commit b4a1845
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "digitalgarden",
"name": "Digital Garden",
"version": "2.49.0",
"version": "2.49.1",
"minAppVersion": "0.12.0",
"description": "Publish your notes to the web for others to enjoy. For free.",
"author": "Ole Eskild Steensen",
Expand Down
18 changes: 14 additions & 4 deletions src/compiler/GardenPageCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,20 @@ export class GardenPageCompiler {

async convertCustomFilters(text: string) {
for (const filter of this.settings.customFilters) {
text = text.replace(
RegExp(filter.pattern, filter.flags),
filter.replace,
);
try {
text = text.replace(
RegExp(filter.pattern, filter.flags),
filter.replace,
);
} catch (e) {
Logger.error(
`Invalid regex: ${filter.pattern} ${filter.flags}`,
);

new Notice(
`Your custom filters contains an invalid regex: ${filter.pattern}. Skipping it.`,
);
}
}

return text;
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"2.49.1": "0.12.0",
"2.49.0": "0.12.0",
"2.48.0": "0.12.0",
"2.47.0": "0.12.0",
Expand Down

0 comments on commit b4a1845

Please sign in to comment.