Extraction of links with valid () chars broken
Closed this issue · 1 comments
I was trying to use this to embed a PDF and it broke on an admittedly unusual URL structure. This is the URL it broke on:
https://www.jacionline.org/article/S0091-6749(16)30948-4/pdf
Specifically, it was getting parsed as this:
https://www.jacionline.org/article/S0091-6749(16)
I finally tracked the problem down to this line's regex:
obsidian-local-images-plus/src/config.ts
Line 15 in a619806
and found it seems to work correctly with this slightly modified version:
/\!\[(?<anchor>(.{0}|.+?))\]\((((?<link>(http(s){0,1}).+?)(\) {1,}|\)$|\)\n|\)\]|\)\[)))/g
with the bonus that this version doesn't capture the termination like the previous version, so no newline and spaces in the result.
Hey. You are showing me the commit from version 0.14.6
obsidian-local-images-plus/src/config.ts
Line 15 in a619806
The latest (published) version of this plugin is 0.15.2
obsidian-local-images-plus/src/config.ts
Line 15 in 8853964
So I think the regex has nothing to do with your issue. I have just tested your link, and found that sometimes it throws CORS errors. This plugin uses obsidian API function to fetch files. That API was designed to avoid those CORS errors and it does it, but probably not in all cases.
Btw, your regex has some redundancies e.g " {1,}", unnecessary brackets.
But thanks for you participation.