Skip to content

Commit

Permalink
Fixed empty path bug (#913)
Browse files Browse the repository at this point in the history
* Removed / from list of disallowed first tokens

Fixes #414

* Changed functionality to allow /

* Formatting change
  • Loading branch information
brycematheson1234 authored and johanbrandhorst committed Mar 27, 2019
1 parent 20f268a commit 01b57e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion protoc-gen-grpc-gateway/httprule/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (p *parser) accept(term termType) (string, error) {
t := p.tokens[0]
switch term {
case "/", "*", "**", ".", "=", "{", "}":
if t != string(term) {
if t != string(term) && t != "/" {
return "", fmt.Errorf("expected %q but got %q", term, t)
}
case typeEOF:
Expand Down
8 changes: 7 additions & 1 deletion protoc-gen-grpc-gateway/httprule/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ func TestParseSegments(t *testing.T) {
literal("v1"),
},
},
{
tokens: []string{"/", eof},
want: []segment{
wildcard{},
},
},
{
tokens: []string{"-._~!$&'()*+,;=:@", eof},
want: []segment{
Expand Down Expand Up @@ -247,7 +253,7 @@ func TestParseSegmentsWithErrors(t *testing.T) {
}{
{
// double slash
tokens: []string{"/", eof},
tokens: []string{"//", eof},
},
{
// invalid literal
Expand Down

0 comments on commit 01b57e6

Please sign in to comment.