Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

baseapp: Allow alphanumerics in routes #1705

Merged
merged 2 commits into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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