YukiGasai / obsidian-google-calendar

Add Google Calendar inside Obsidian
https://yukigasai.github.io/obsidian-google-calendar/
GNU General Public License v3.0
359 stars 25 forks source link

Update AutoEventNoteCreator.ts #155

Open JamesParkNINJA opened 1 year ago

JamesParkNINJA commented 1 year ago

Fixes an error where a trailing "-" is added as part of the first match, instead of outside of the match, rendering the custom folder structure incorrect and preventing the imported events from moving out of the base folder

YukiGasai commented 1 year ago

Hi, I check your changes and don't understand them fully. I tested the regex on this page with some options that can occur. The change you made will force the user to always add the "-" in front of the marker word. Could you please give an example where the current Regex will not work?

The trailing "-" is removed later from the path https://github.com/YukiGasai/obsidian-google-calendar/blob/a6665ac5b42c445026f5ca52d3c64dee044b07de/src/helper/AutoEventNoteCreator.ts#L190-L193

dabalroman commented 1 month ago

I studied this while working on #267 and it also threw me off for a moment. This PR would actually break the assumptions made in documentation of Auto create EventNotes.

The hypen is captured by first capturing group due to the regex greedy nature. This behaviour cannot be easily fixed without breaking the support for hypens in directory name. The solution with removeing the hypen later is quite weird, but it works, so there is nothing to fix here.