Skip to content

Commit

Permalink
🐛 fix titles with apostrophes not being recognized like file path
Browse files Browse the repository at this point in the history
  • Loading branch information
ulisesantana committed Oct 19, 2023
1 parent cf12d9a commit b5646b0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/Notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface NotePendingToBeCreated {
}

export class Notes {
private static filePathExpression = /^[\p{L}\p{N}_\p{Pd}\p{Emoji} ]+(\/[\p{L}\p{N}_\p{Pd}\p{Emoji} ]+)*(\.[\p{L}\p{N}_\p{Pd}]+)?$/u
private static filePathExpression = /^[\p{L}\p{N}_\p{Pd}\p{Emoji}\p{P} ]+(\/[\p{L}\p{N}_\p{Pd}\p{Emoji}\p{P} ]+)*(\.[\p{L}\p{N}_\p{Pd}\p{Emoji}\p{P}]+)?$/u;
private static templaterExpression = /<%.*%>/
private static wikiLinksExpression = /(?:[^!]|^)\[\[(.+?)]]/g

Expand Down
43 changes: 43 additions & 0 deletions test/core/Notes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,48 @@ describe('Notes should', () => {
}
])
});

it('handling apostrophes', async () => {
const pending = await Notes.getPendingToCreate([
{
"name": "Test",
"content": Promise.resolve("This should recognize one [[notes/Pending note]]. Because [[Pending note]] another [[notes/Pending note.md]]. Check [[Fulano's legend]]"),
"extension":"md",
"path":"notes/Test.md",
},
{
"name": "Pending note",
"content": Promise.resolve("Is note that is [[Outlinks|linked]], but not created yet. Also, you can check [[notes/Ambrosio's legend]]"),
"extension":"md",
"path":"notes/Pending note.md",
},
{
"name": "Ambrosio's legend",
"content": Promise.resolve("Ambrosio was an exceptional man. He can enter into a bar and keep quiet hearing cuñaos talking about solving the world."),
"extension":"md",
"path":"notes/Ambrosio's legend.md",
},
{
"name": "Fulano's legend",
"content": Promise.resolve("Fulano was an exceptional man. Much more than [[notes/Mengano's story]] and [[Rodolfo's story]]"),
"extension":"md",
"path":"notes/Fulano's legend.md",
},
])
expect(pending).toEqual([
{
"timesLinked": 1,
"title": "notes/Mengano's story"
},
{
"timesLinked": 1,
"title": "Outlinks"
},
{
"timesLinked": 1,
"title": "Rodolfo's story"
}
])
});
});
});

0 comments on commit b5646b0

Please sign in to comment.