Skip to content

Commit

Permalink
valid id
Browse files Browse the repository at this point in the history
  • Loading branch information
hbagdi committed Feb 20, 2022
1 parent f19539f commit f563300
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strings"
)

var idRegex = regexp.MustCompile(`^@[a-zA-Z][a-z-A-Z0-9-_]+$`)

type File struct {
Global Global
Requests []Request
Expand Down Expand Up @@ -50,6 +52,9 @@ func Parse(filename string) (File, error) {
return File{}, err
}
case strings.HasPrefix(line, "@"):
if !idRegex.MatchString(line) {
return File{}, fmt.Errorf("invalid id: '%v'", line)
}
id := line[1:]
req, err := request(id, sc)
if err != nil {
Expand Down

0 comments on commit f563300

Please sign in to comment.