Skip to content

Add support for local files, even without arguments (fix #35) #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 26, 2024

Conversation

Mideks
Copy link
Contributor

@Mideks Mideks commented Feb 26, 2024

I think it's fix for #35
Now all of those links are correct:
C:...\image.png
C:...\image.png?
C:...\image.png?123
file:\C:...\image.png
file:\C:...\image.png?
file:\C:...\image.png?123

I think it's fix for nicojeske#35
Now all of those links are correct:
C:\...\image.png
C:\...\image.png?
C:\...\image.png?123
file:\\C:\...\image.png
file:\\C:\...\image.png?
file:\\C:\...\image.png?123
@Mideks Mideks changed the title Add support for local files, even without arguments Add support for local files, even without arguments (#35) Feb 26, 2024
@Mideks Mideks changed the title Add support for local files, even without arguments (#35) Add support for local files, even without arguments (fix #35) Feb 26, 2024
@nicojeske
Copy link
Owner

Your approach handles these local files but then fails to recognize images that were embedded via the Obsidian Syntax (i.e. ![[image.jpg]]).

These image get a path ending with a query parameter e.g. app://4de8acc508e45a4cd7f12451e76d83dbb293/C:/.../image.png?1754515

Your regex includes the query part so the function would return image.png?1754515. This can then not be matched in the file as the query part is appended by obsidian.

I will add a commit with a new Regex that (hopefully) covers all cases. I think we can safely disregard the handling of query parameters for local files as ? is not allowed in filenames.

Introduce a regex that also works on local files. Local files also support the usage of either / or \ in the path.
@nicojeske nicojeske merged commit 2cf815c into nicojeske:master Feb 26, 2024
@Mideks
Copy link
Contributor Author

Mideks commented Feb 26, 2024

Hmm, really missed that way of attaching files when I was testing. And I was thinking "why would a file path even have a construct with arguments...?". Turns out that's why :)
Actually, I was thinking about a similar one to your regular expression, but decided to cut it down for unnecessary, huh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants