Skip to content

Commit

Permalink
fix: 🐛 fix: Filter illegal uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenull committed Jan 20, 2024
1 parent 8d5fae2 commit 5d311e8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Agenda3/helpers/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,13 @@ function replacePageReference(text: string) {
*/
async function replaceBlockReference(text: string): Promise<string> {
const blockIds = Array.from(text.matchAll(/\(\(([\w-]+)\)\)/g)).map((match) => match[1])
const blocks = await Promise.all(blockIds.map((uuid) => logseq.Editor.getBlock(uuid)))
const blocks = await Promise.all(
blockIds.map((uuid) => {
// if not a valid uuid, return null
if (!uuid.match(/^[\w-]{31,}$/)) return null
return logseq.Editor.getBlock(uuid)
}),
)
blocks.forEach((block, index) => {
if (block?.content) {
const firstLine = block.content.split('\n')[0]
Expand Down

0 comments on commit 5d311e8

Please sign in to comment.