From 66bc027c4e18ebc788f4396c22ea74c057707df8 Mon Sep 17 00:00:00 2001
From: Chris Grieser <73286100+chrisgrieser@users.noreply.github.com>
Date: Fri, 29 Mar 2024 21:56:28 +0100
Subject: [PATCH] fix: error when multiple attachments (#45)
---
README.md | 2 +-
scripts/write-citation-picker-buffer.js | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index fe88263..746a547 100644
--- a/README.md
+++ b/README.md
@@ -213,7 +213,7 @@ specified in your workflow settings.
queries (see: [smart queries](#search)).
- A `📎` indicates that the BibTeX entry has a `file` or `attachment` field. You
can use ⌃⌥⌘⏎ to open the
- attachment.
+ attachment. If there are multiple attachments, the first one is opened.
### Link Preview
- Install the
diff --git a/scripts/write-citation-picker-buffer.js b/scripts/write-citation-picker-buffer.js
index 7692e7c..d41d043 100755
--- a/scripts/write-citation-picker-buffer.js
+++ b/scripts/write-citation-picker-buffer.js
@@ -228,7 +228,9 @@ function bibtexParse(rawBibtexStr) {
}
case "file":
case "attachment": {
- entry.attachment = value;
+ // see https://github.com/chrisgrieser/alfred-bibtex-citation-picker/issues/45
+ const multipleAttachments = value.includes(";/Users/");
+ entry.attachment = multipleAttachments ? value.split(";/Users/")[0] : value;
break;
}
default: