Skip to content

Commit

Permalink
adds # and @ to allowable keyword characters
Browse files Browse the repository at this point in the history
  • Loading branch information
vilenarios committed Oct 16, 2024
1 parent 66fc768 commit 9884702
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions spec/ant_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/common/balances.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9884702

Please sign in to comment.