[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hyperdrive c19696aaf6 01/31: Chore: Favor format over conc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hyperdrive c19696aaf6 01/31: Chore: Favor format over concat when constructing URLs |
Date: |
Fri, 1 Dec 2023 01:00:37 -0500 (EST) |
branch: elpa/hyperdrive
commit c19696aaf6b6bc1088418f1f7d17e82012767506
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Joseph Turner <joseph@ushin.org>
Chore: Favor format over concat when constructing URLs
In some cases we can now avoid having to use `number-to-string'.
This also leads to more natural results, when having to add line-
breaks to avoid long lines.
Co-authored-by: Joseph Turner <joseph@ushin.org>
---
hyperdrive-lib.el | 8 +++++---
hyperdrive.el | 2 +-
tests/test-hyperdrive.el | 17 +++++++++--------
3 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index 144585eeea..5b7893d7bb 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -219,12 +219,13 @@ PLZ-ERR should be a `plz-error' struct."
"Return non-nil if `hyper-gateway' is running and accessible."
;; FIXME: Ensure a very short timeout for this request.
(condition-case nil
- (plz 'get (concat "http://localhost:" (number-to-string
h/hyper-gateway-port) "/"))
+ (plz 'get (format "http://localhost:%d/" h/hyper-gateway-port))
(error nil)))
(defun h//httpify-url (url)
"Return localhost HTTP URL for HYPER-URL."
- (concat "http://localhost:" (number-to-string h/hyper-gateway-port) "/hyper/"
+ (format "http://localhost:%d/hyper/%s"
+ h/hyper-gateway-port
(substring url (length h//hyper-prefix))))
(cl-defun h//write (url &key body then else queue)
@@ -1208,7 +1209,8 @@ With PURGE, delete hash table entry for HYPERDRIVE."
That is, if the SEED has been used to create a local
hyperdrive."
(condition-case err
- (pcase (h/api 'get (concat "hyper://localhost/?key=" (url-hexify-string
seed))
+ (pcase (h/api 'get (format "hyper://localhost/?key=%s"
+ (url-hexify-string seed))
:as 'response :noquery t)
((and (pred plz-response-p)
response
diff --git a/hyperdrive.el b/hyperdrive.el
index 6036ecab6f..6cba22c3b0 100644
--- a/hyperdrive.el
+++ b/hyperdrive.el
@@ -112,7 +112,7 @@
Gateway must be running."
(interactive)
(condition-case err
- (let ((url (concat "http://localhost:" (number-to-string
h/hyper-gateway-port) "/")))
+ (let ((url (format "http://localhost:%d/" h/hyper-gateway-port)))
(h/message "hyper-gateway version %s"
(alist-get 'version (plz 'get url :as #'json-read))))
(plz-error (h/api-default-else nil (caddr err)))))
diff --git a/tests/test-hyperdrive.el b/tests/test-hyperdrive.el
index 64baf43e7b..4a9897088b 100644
--- a/tests/test-hyperdrive.el
+++ b/tests/test-hyperdrive.el
@@ -117,21 +117,22 @@
(h/deftest entry-url-round-trip ()
(let ((url (he/url (h/url-entry (make-url "")))))
- (should (equal url (concat "hyper://" test-hyperdrive-public-key "/"))))
+ (should (equal url (format "hyper://%s/" test-hyperdrive-public-key))))
(let ((url (he/url (h/url-entry (make-url "/")))))
- (should (equal url (concat "hyper://" test-hyperdrive-public-key "/"))))
+ (should (equal url (format "hyper://%s/" test-hyperdrive-public-key))))
(let ((url (he/url (h/url-entry (make-url "/name-without-spaces")))))
- (should (equal url (concat "hyper://" test-hyperdrive-public-key
"/name-without-spaces"))))
+ (should (equal url (format "hyper://%s/name-without-spaces"
+ test-hyperdrive-public-key))))
(let ((url (he/url (h/url-entry (make-url "/name%20without%20spaces")))))
- (should (equal url (concat "hyper://" test-hyperdrive-public-key
"/name%20without%20spaces"))))
+ (should (equal url (format "hyper://%s/name%%20without%%20spaces"
+ test-hyperdrive-public-key))))
- (let ((url (he/url (h/url-entry
- (make-url "/name%20without%20spaces/subdir")))))
- (should (equal url (concat "hyper://" test-hyperdrive-public-key
- "/name%20without%20spaces/subdir")))))
+ (let ((url (he/url (h/url-entry (make-url
"/name%20without%20spaces/subdir")))))
+ (should (equal url (format "hyper://%s/name%%20without%%20spaces/subdir"
+ test-hyperdrive-public-key)))))
;; Local Variables:
;; read-symbol-shorthands: (
- [nongnu] elpa/hyperdrive updated (ab3cc72ed2 -> cc4f2caddc), ELPA Syncer, 2023/12/01
- [nongnu] elpa/hyperdrive 2a72072183 02/31: Chore: Dissolve outer format into inner h//format, ELPA Syncer, 2023/12/01
- [nongnu] elpa/hyperdrive fac9e009c5 04/31: Chore: Use defun-style line-wrapping in cl-{macrolet, labels}, ELPA Syncer, 2023/12/01
- [nongnu] elpa/hyperdrive f79591ae3b 03/31: Chore: Use \n instead of newline character in format strings, ELPA Syncer, 2023/12/01
- [nongnu] elpa/hyperdrive c19696aaf6 01/31: Chore: Favor format over concat when constructing URLs,
ELPA Syncer <=
- [nongnu] elpa/hyperdrive cc4e9c2507 06/31: Chore: Begin cl-labels' BINDINGS on a new line, ELPA Syncer, 2023/12/01
- [nongnu] elpa/hyperdrive 6bd2ae7036 07/31: Chore: Begin format-spec's FORMAT and SPECIFICATION on new lines, ELPA Syncer, 2023/12/01
- [nongnu] elpa/hyperdrive 9c11d63570 25/31: Merge branch 'cleanup', ELPA Syncer, 2023/12/01
- [nongnu] elpa/hyperdrive 3c537e9b78 23/31: Chore: Minor whitespace cleanup, ELPA Syncer, 2023/12/01
- [nongnu] elpa/hyperdrive 1e8c2f0973 24/31: Chore: Use semantically correct contitionals, ELPA Syncer, 2023/12/01
- [nongnu] elpa/hyperdrive 6b9bc701e5 14/31: Chore: Shorten long lines in hd/dir-handler, ELPA Syncer, 2023/12/01
- [nongnu] elpa/hyperdrive 8131f9afbf 16/31: Chore: Shorten long lines in h/history--format-range-entry, ELPA Syncer, 2023/12/01
- [nongnu] elpa/hyperdrive 772cea7acf 15/31: Chore: Shorten long lines in h/diff-file-entries, ELPA Syncer, 2023/12/01
- [nongnu] elpa/hyperdrive cc4f2caddc 31/31: Change: (h/org--link) Return plist, not alist, ELPA Syncer, 2023/12/01
- [nongnu] elpa/hyperdrive 3b6d5eb3d3 28/31: Docs: Document hyperdrive-gateway-process-type, ELPA Syncer, 2023/12/01