File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -357,5 +357,22 @@ ruleTest({
357357 # [test \#4](github.com/platers/obsidian-linter)
358358 ` ,
359359 } ,
360+ {
361+ testName : 'Only matches and replaces the correct title key, not similar keys' ,
362+ before : dedent `
363+ ---
364+ title2: ShouldNotChange
365+ title: ShouldChange
366+ ---
367+ # Hello world
368+ ` ,
369+ after : dedent `
370+ ---
371+ title2: ShouldNotChange
372+ title: Hello world
373+ ---
374+ # Hello world
375+ ` ,
376+ } ,
360377 ] ,
361378} ) ;
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ export default class YamlTitle extends RuleBuilder<YamlTitleOptions> {
5151 title = escapeStringIfNecessaryAndPossible ( title , options . defaultEscapeCharacter ) ;
5252
5353 return formatYAML ( text , ( text ) => {
54- const title_match_str = `\n${ options . titleKey } .*\n` ;
54+ const title_match_str = `\n${ options . titleKey } : .*\n` ;
5555 const title_match = new RegExp ( title_match_str ) ;
5656 if ( title_match . test ( text ) ) {
5757 text = text . replace (
You can’t perform that action at this time.
0 commit comments