From 3dc3e258b4a4bfee4ff8bfaa91ab1bbc7af29f5f Mon Sep 17 00:00:00 2001 From: alexjgriffith Date: Sat, 24 Feb 2018 14:19:11 -0500 Subject: Check if an id is a number before attempting to convert it. Closes #150 --- lisp/mastodon-tl.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 66452dd..9acf51a 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -267,7 +267,9 @@ also render the html" "&" "?") "max_id=" - (number-to-string id))))) + (if (numberp id ) + (number-to-string id) + id))))) (mastodon-http--get-json url))) ;; TODO @@ -280,7 +282,9 @@ also render the html" "&" "?") "since_id=" - (number-to-string id))))) + (if (numberp id) + (number-to-string id) + id))))) (mastodon-http--get-json url))) (defun mastodon-tl--property (prop &optional backward) -- cgit v1.2.3 From c268e92f9cf66ab6109d1735beeba92b5d87264c Mon Sep 17 00:00:00 2001 From: alexjgriffith Date: Sun, 25 Feb 2018 14:27:47 -0500 Subject: Added tests to ensure that ids passed to mastodon-tl--updated-json and mastodon-tl--more-json work as both strings and integers --- test/mastodon-tl-tests.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/mastodon-tl-tests.el b/test/mastodon-tl-tests.el index 8c706f5..d22a169 100644 --- a/test/mastodon-tl-tests.el +++ b/test/mastodon-tl-tests.el @@ -103,6 +103,26 @@ (mock (mastodon-http--get-json "https://instance.url/api/v1/timelines/foo?max_id=12345")) (mastodon-tl--more-json "timelines/foo" 12345)))) +(ert-deftest more-json-id-string () + "Should request toots older than max_id. + +`mastodon-tl--more-json' should accept and id that is either +a string or a numeric." + (let ((mastodon-instance-url "https://instance.url")) + (with-mock + (mock (mastodon-http--get-json "https://instance.url/api/v1/timelines/foo?max_id=12345")) + (mastodon-tl--more-json "timelines/foo" "12345")))) + +(ert-deftest update-json-id-string () + "Should request toots more recent than since_id. + +`mastodon-tl--updated-json' should accept and id that is either +a string or a numeric." + (let ((mastodon-instance-url "https://instance.url")) + (with-mock + (mock (mastodon-http--get-json "https://instance.url/api/v1/timelines/foo?since_id=12345")) + (mastodon-tl--updated-json "timelines/foo" "12345")))) + (ert-deftest mastodon-tl--byline-regular () "Should format the regular toot correctly." (let ((mastodon-tl--show-avatars-p nil) -- cgit v1.2.3