From bc0eb7023b988b45d8b475aef92c8a71283e2c34 Mon Sep 17 00:00:00 2001 From: Bram Schoenmakers Date: Thu, 11 Jan 2024 19:20:39 +0100 Subject: [PATCH] Detect URL properly, such that correct API call is made This fixes issue #2. Whenever a text contains an URL anywhere, the kagi-url-p function would return positive and the text is submitted as an URL to the Kagi Summarizer API. Now this is only done when the string is a URL only, otherwise the text summarizer is invoked. --- kagi.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kagi.el b/kagi.el index 9c85cb7..50cfee7 100644 --- a/kagi.el +++ b/kagi.el @@ -337,7 +337,7 @@ Returns a formatted string to be displayed by the shell." (defun kagi--url-p (s) "Non-nil if string S is a URL." - (string-match-p (rx (seq "http" (? "s") "://")) s)) + (string-match-p (rx (seq bos "http" (? "s") "://" (+ (not space)) eos)) s)) ;;;###autoload (defun kagi-summarize (text-or-url)