Cleaned up URL parameter handling.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
diff --git a/gravatar.lisp b/gravatar.lisp
index 1224cce..63c423b 100644
--- a/gravatar.lisp
+++ b/gravatar.lisp
@@ -15,23 +15,24 @@
:identicon, :monsterid, :wavatar, or :retro. RATING may be one of :g, :pg,
:r, or :x."
(let ((parameters ()))
- (when size (push (format nil "s=~d" size) parameters))
+ (when size (push `("s" . ,(format nil "~d" size)) parameters))
(typecase default
- (keyword (push (format nil "d=~a" (string-downcase default)) parameters))
- (string (push (format nil "d=~a" default) parameters)))
- (when force-default-p (push "f=y" parameters))
- (when rating (push (format nil "r=~a" (string-downcase rating)) parameters))
- (puri:merge-uris (format nil "avatar/~a~@[?~{~a~^&~}~]"
- (hash email) parameters)
+ (keyword (push `("d" . ,(string-downcase default)) parameters))
+ (string (push `("d" . ,default) parameters)))
+ (when force-default-p (push '("f" . "y") parameters))
+ (when rating (push `("r" . ,(string-downcase rating)) parameters))
+ (puri:merge-uris (format nil "avatar/~a~@[?~a~]"
+ (hash email)
+ (drakma::alist-to-url-encoded-string parameters
+ :utf-8))
+base-uri+)))
(defun generate-profile-url (email type parameters)
- (puri:merge-uris (format nil "g2-~a.~a~@[?~:{~a=~a~^&~}~]"
+ (puri:merge-uris (format nil "g2-~a.~a~@[?~a~]"
(hash email)
(string-downcase type)
- (mapcar (lambda (parameter)
- (list (car parameter) (cdr parameter)))
- parameters))
+ (drakma::alist-to-url-encoded-string parameters
+ :utf-8))
+base-uri+))
(defun profile (email &optional js-callback)
@@ -44,4 +45,6 @@
`(("callback" . ,js-callback))))))))
(defun qr-code-url (email &optional size)
- (generate-profile-url email :qr (when size `(("s" . ,size)))))
+ (generate-profile-url email
+ :qr
+ (when size `(("s" . ,(format nil "~d" size))))))