From f391e13ddb1fcd8a0a4daf033f341532060f7421 Mon Sep 17 00:00:00 2001 From: unwox Date: Thu, 14 Nov 2024 10:35:07 +0600 Subject: specify canonical URL for SEO --- lib/string.fnl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/string.fnl') diff --git a/lib/string.fnl b/lib/string.fnl index 3e6134e..c722bd3 100644 --- a/lib/string.fnl +++ b/lib/string.fnl @@ -32,8 +32,9 @@ (fn ends-with [str end] (= (string.sub str (- (# end))) end)) -(fn trim [str] - (str:match "^%s*(.-)%s*$")) +(fn trim [str pattern] + (local pattern (or pattern "%s")) + (str:match (.. "^" pattern "*(.-)" pattern "*$"))) (fn truncate [str len ellipsis] (if (and (= (type str) "string") -- cgit v1.2.3