Changeset

3029:7878dc2dbf59

mod_pastebin: Avoid using pattern matching facilities for simple prefix removal
author Kim Alvefur <zash@zash.se>
date Sun, 20 May 2018 17:51:08 +0200
parents 3028:ded630a87563
children 3030:4a7f08fe793c
files mod_pastebin/mod_pastebin.lua
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_pastebin/mod_pastebin.lua	Sun May 20 17:49:00 2018 +0200
+++ b/mod_pastebin/mod_pastebin.lua	Sun May 20 17:51:08 2018 +0200
@@ -113,8 +113,8 @@
 		(trigger_string and body:find(trigger_string, 1, true) == 1) or
 		(select(2, body:gsub("\n", "%0")) >= line_threshold)
 	) then
-		if trigger_string then
-			body = body:gsub("^" .. trigger_string, "", 1);
+		if trigger_string and body:sub(1, #trigger_string) == trigger_string then
+			body = body:sub(#trigger_string+1);
 		end
 		local url = pastebin_text(body);
 		module:log("debug", "Pasted message as %s", url);