From 530360474a99fdffba5c7e3db38d369a3514b599 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Tue, 5 Jul 2022 11:34:58 +0200 Subject: [PATCH] text: Minor cleanup --- text.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/text.lua b/text.lua index a237d7d..f3f7eac 100644 --- a/text.lua +++ b/text.lua @@ -9,9 +9,9 @@ function upper_first(text) return text:sub(1, 1):upper() .. text:sub(2) end function lower_first(text) return text:sub(1, 1):lower() .. text:sub(2) end -function starts_with(text, start) return text:sub(1, start:len()) == start end +function starts_with(text, prefix) return text:sub(1, #prefix) == prefix end -function ends_with(text, suffix) return text:sub(text:len() - suffix:len() + 1) == suffix end +function ends_with(text, suffix) return text:sub(-#suffix) == suffix end function trim(text, to_remove) local j = 1 @@ -188,4 +188,4 @@ function is_identifier(text) end -- Export environment -return _ENV \ No newline at end of file +return _ENV