From 9884702e9144fe14c2b1899b5fef58deb4ffa2ad Mon Sep 17 00:00:00 2001 From: Philip Mataras Date: Wed, 16 Oct 2024 19:04:00 -0400 Subject: [PATCH] adds # and @ to allowable keyword characters --- spec/ant_spec.lua | 4 ++-- src/common/balances.lua | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/ant_spec.lua b/spec/ant_spec.lua index 6d8acb5..d2fb754 100644 --- a/spec/ant_spec.lua +++ b/spec/ant_spec.lua @@ -146,10 +146,10 @@ describe("Arweave Name Token", function() -- Test when keywords contain invalid characters it("throws an error if keywords contain invalid characters", function() - local keywordsWithSpecialChars = { "valid", "inva@lid" } -- Contains special character '@' + local keywordsWithSpecialChars = { "valid", "inva!lid" } -- Contains special character '!' assert.has_error(function() balances.setKeywords(keywordsWithSpecialChars) - end, "Keywords must only contain alphanumeric characters, dashes, or underscores") + end, "Keywords must only contain alphanumeric characters, dashes, underscores, #, or @") end) -- Test when any keyword is duplicated diff --git a/src/common/balances.lua b/src/common/balances.lua index 01797df..5420ecb 100644 --- a/src/common/balances.lua +++ b/src/common/balances.lua @@ -54,8 +54,10 @@ function balances.setKeywords(keywords) assert(type(keyword) == "string", "Each keyword must be a string") assert(#keyword <= 32, "Each keyword must not be longer than 32 characters") assert(not keyword:find("%s"), "Keywords must not contain spaces") - assert(keyword:match("^[%w-_]+$"), "Keywords must only contain alphanumeric characters, dashes, or underscores") - + assert( + keyword:match("^[%w-_#@]+$"), + "Keywords must only contain alphanumeric characters, dashes, underscores, #, or @" + ) -- Check for duplicates assert(not seenKeywords[keyword], "Duplicate keyword detected: " .. keyword) seenKeywords[keyword] = true