Skip to content

Commit

Permalink
baseapp: Allow alphanumerics in routes
Browse files Browse the repository at this point in the history
Previously only alphabetic characters were allowed.

Closes #1587
  • Loading branch information
ValarDragon committed Jul 17, 2018
1 parent 888aea4 commit deea52a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## PENDING

IMPROVEMENTS
* [baseapp] Allow any alphanumeric character in route

## 0.22.0

*July 16th, 2018*
Expand Down
2 changes: 1 addition & 1 deletion baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (tx txTest) GetMsgs() []sdk.Msg { return tx.Msgs }

const (
typeMsgCounter = "msgCounter"
typeMsgCounter2 = "msgCounterTwo" // NOTE: no numerics (?)
typeMsgCounter2 = "msgCounter2"
)

// ValidateBasic() fails on negative counters.
Expand Down
6 changes: 3 additions & 3 deletions baseapp/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ func NewRouter() *router {
}
}

var isAlpha = regexp.MustCompile(`^[a-zA-Z]+$`).MatchString
var isAlphaNumeric = regexp.MustCompile(`^[a-zA-Z0-9]+$`).MatchString

// AddRoute - TODO add description
func (rtr *router) AddRoute(r string, h sdk.Handler) Router {
if !isAlpha(r) {
panic("route expressions can only contain alphabet characters")
if !isAlphaNumeric(r) {
panic("route expressions can only contain alphanumeric characters")
}
rtr.routes = append(rtr.routes, route{r, h})

Expand Down

0 comments on commit deea52a

Please sign in to comment.