chhoumann / quickadd

QuickAdd for Obsidian
https://quickadd.obsidian.guide
MIT License
1.56k stars 139 forks source link

fix: replaceLinebreakInString bug with double newlines #752

Open edongashi opened 2 weeks ago

edongashi commented 2 weeks ago

Replaces regex with a simple state machine.

Since there is no test infrastructure, I ran the following snippet for a sanity check:

console.log([
  "Line1\\Line2",
  "Line1\\\\Line2",
  "Line1\\tLine2",
  "Line1\\nLine2",
  "Line1\\n\\nLine2",
  "Line1\\n\\\\nLine2",
  "Line1\\n\\\\\\nLine2",
].map(replaceLinebreakInString).join('\n======\n'))

And got:

Line1\Line2
======
Line1\Line2
======
Line1\tLine2
======
Line1
Line2
======
Line1

Line2
======
Line1
\nLine2
======
Line1
\
Line2
vercel[bot] commented 2 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
quickadd ✅ Ready (Inspect) Visit Preview Nov 3, 2024 2:33am