Skip to content

Commit

Permalink
chore: remove board name format check
Browse files Browse the repository at this point in the history
This check might be reintroduced in the default permissioner
implementation.
  • Loading branch information
jeronimoalbi committed Nov 18, 2024
1 parent f444a1b commit 43980fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
11 changes: 0 additions & 11 deletions examples/gno.land/r/demo/boards2/board.gno
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package boards

import (
"regexp"
"std"
"strconv"
"strings"
Expand All @@ -11,8 +10,6 @@ import (
"gno.land/p/moul/txlink"
)

var reBoardName = regexp.MustCompile(`^[a-z]{3}[_a-z0-9]{0,23}[0-9]{3}$`)

type BoardID uint64

func (id BoardID) String() string {
Expand All @@ -34,8 +31,6 @@ type Board struct {
}

func newBoard(id BoardID, name string, creator std.Address) *Board {
assertIsBoardName(name)

if gBoardsByName.Has(name) {
panic("board already exists")
}
Expand Down Expand Up @@ -121,9 +116,3 @@ func (board *Board) GetURLFromReplyID(threadID, replyID PostID) string {
func (board *Board) GetPostFormURL() string {
return txlink.URL("CreateThread", "bid", board.id.String())
}

func assertIsBoardName(name string) {
if !reBoardName.MatchString(name) {
panic("invalid board name: " + name)
}
}
6 changes: 6 additions & 0 deletions examples/gno.land/r/demo/boards2/public.gno
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package boards

import (
"std"
"strings"

"gno.land/r/demo/users"
)
Expand All @@ -17,6 +18,11 @@ func GetBoardIDFromName(name string) (BoardID, bool) {
func CreateBoard(name string) BoardID {
assertIsUserCall()

name = strings.TrimSpace(name)
if name == "" {
panic("board name is empty")
}

caller := std.GetOrigCaller()
assertIsNotAnonymousCaller(caller)

Expand Down

0 comments on commit 43980fd

Please sign in to comment.