diff options
Diffstat (limited to 'web/panettone/src/util.lisp')
-rw-r--r-- | web/panettone/src/util.lisp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/web/panettone/src/util.lisp b/web/panettone/src/util.lisp new file mode 100644 index 000000000000..2abedf7b8fbb --- /dev/null +++ b/web/panettone/src/util.lisp @@ -0,0 +1,15 @@ +(in-package :panettone.util) + +(defun integer-env (var &key default) + (or + (when-let ((str (uiop:getenvp var))) + (try-parse-integer str)) + default)) + +(defun add-missing-base64-padding (s) + "Add any missing padding characters to the (un-padded) base64 string `S', such +that it can be successfully decoded by the `BASE64' package" + ;; I apologize + (let* ((needed-padding (mod (length s) 4)) + (pad-chars (if (zerop needed-padding) 0 (- 4 needed-padding)))) + (format nil "~A~v@{~A~:*~}" s pad-chars "="))) |