From 3dbb6038311b5af7b28d7a9ec0ad5916ebf14531 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 17 Sep 2022 11:46:14 +0100 Subject: [PATCH] add slugify function to utils package. This replaces white spaces in a string with a hyphen ('-'). I prefer file names to be stored with no white space, which is where I intend to use this function the most. --- src/utils.lisp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils.lisp b/src/utils.lisp index b5361a1..4c3b553 100644 --- a/src/utils.lisp +++ b/src/utils.lisp @@ -14,7 +14,9 @@ #:get-alert #:get-and-reset-alert #:bool-to-checkbox - #:checkbox-to-bool) + #:checkbox-to-bool + #:asciify + #:slugify) (:documentation "Utilities that do not depend on models.")) (in-package #:utils) @@ -22,6 +24,10 @@ (defun asciify (string) (str:downcase (slug:asciify string))) +(defun slugify (string) + "Turns a string of text into a slug." + (str:downcase (slug:slugify string))) + (defun request-params (request) (loop :for (key . value) :in request :collect (let ((*package* (find-package :keyword)))