Skip to content

Commit

Permalink
Merge PR #1705: baseapp: Allow alphanumerics in routes
Browse files Browse the repository at this point in the history
Previously only alphabetic characters were allowed.
  • Loading branch information
ValarDragon authored and cwgoes committed Jul 17, 2018
1 parent d6969c1 commit f88d644
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Changelog

## TBD
## PENDING

BREAKING CHANGES

FEATURES
* [lcd] Can now query governance proposals by ProposalStatus

IMPROVEMENTS
* [baseapp] Allow any alphanumeric character in route

BUG FIXES

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 f88d644

Please sign in to comment.