Skip to content

Commit

Permalink
Merge pull request #1027 from pjkaufman/master
Browse files Browse the repository at this point in the history
Fix: Undefined Custom Regex Label Causes Error
  • Loading branch information
pjkaufman authored Feb 28, 2024
2 parents 59bac09 + d3e1798 commit b87f0e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions __tests__/rules-runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,22 @@ const customReplaceTestCases: CustomReplaceTestCase[] = [
<!-- linter-enable -->
`,
},
{ // accounts for https://github.com/platers/obsidian-linter/issues/1025
testName: 'A custom replace with an undefined label should still run.',
listOfRegexReplacements: [
{
label: undefined, find: 'lobo', replace: 'hello', flags: 'g',
},
],
before: dedent`
How does this look?
Did it stay the same?
`,
after: dedent`
How does this look?
Did it stay the same?
`,
},
];

describe('Rules Runner', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/rules-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class RulesRunner {
}

let debugMsg = eachRegex.label;
if (debugMsg.trim() != '') {
if (debugMsg && debugMsg.trim() != '') {
debugMsg += ':\n';
}
debugMsg +=`/${eachRegex.find}/${eachRegex.flags}/${eachRegex.replace}/`;
Expand Down

0 comments on commit b87f0e2

Please sign in to comment.