mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(fix): do not store empty-string refs in db (#586)
* (fix): do not store empty-string refs in db * Error when ROAM_KEY is empty * Handle nil Co-authored-by: Jethro Kuan <jethrokuan95@gmail.com>
This commit is contained in:
18
org-roam.el
18
org-roam.el
@ -382,13 +382,17 @@ current buffer is used."
|
||||
|
||||
(defun org-roam--extract-ref ()
|
||||
"Extract the ref from current buffer and return the type and the key of the ref."
|
||||
(if-let ((ref (cdr (assoc "ROAM_KEY" (org-roam--extract-global-props '("ROAM_KEY"))))))
|
||||
(let* ((type (org-roam--ref-type ref))
|
||||
(key (cond ((string= "cite" type)
|
||||
(s-chop-prefix (org-roam--cite-prefix ref) ref))
|
||||
(t ref))))
|
||||
(cons type key))
|
||||
nil))
|
||||
(pcase (cdr (assoc "ROAM_KEY"
|
||||
(org-roam--extract-global-props '("ROAM_KEY"))))
|
||||
('nil nil)
|
||||
((pred string-empty-p)
|
||||
(user-error "ROAM_KEY cannot be empty"))
|
||||
(ref
|
||||
(let* ((type (org-roam--ref-type ref))
|
||||
(key (cond ((string= "cite" type)
|
||||
(s-chop-prefix (org-roam--cite-prefix ref) ref))
|
||||
(t ref))))
|
||||
(cons type key)))))
|
||||
|
||||
(defun org-roam--ref-type (ref)
|
||||
"Determine the type of the REF from the prefix."
|
||||
|
Reference in New Issue
Block a user