logical/framework: Panic if routing pattern is blank

This commit is contained in:
Armon Dadgar 2015-04-01 17:56:03 -07:00
parent ca5c55c3eb
commit faa759ea1d

View file

@ -129,8 +129,11 @@ func (b *Backend) Secret(k string) *Secret {
func (b *Backend) init() {
b.pathsRe = make([]*regexp.Regexp, len(b.Paths))
for i, p := range b.Paths {
if len(p.Pattern) == 0 {
panic(fmt.Sprintf("Routing pattern cannot be blank"))
}
// Automatically anchor the pattern
if len(p.Pattern) > 0 && p.Pattern[0] != '^' {
if p.Pattern[0] != '^' {
p.Pattern = "^" + p.Pattern
}
if p.Pattern[len(p.Pattern)-1] != '$' {