Skip to content

Commit

Permalink
Merge pull request #4 from mistweaverco/fix/formatting-whitespace-hea…
Browse files Browse the repository at this point in the history
…ders-lowercase

fix(parser): body whitespace mangling + trim/lower headers
  • Loading branch information
gorillamoe authored Jul 22, 2024
2 parents 5043069 + 41668fb commit 9bf45f5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ func parseSection(section string, document *Document) Section {
} else if strings.HasPrefix(line, "# @") {
parsedSection.Metadata = append(parsedSection.Metadata, line)
continue
} else if strings.HasPrefix(line, "#") {
} else if strings.HasPrefix(line, "#") || strings.HasPrefix(line, "//") {
if strings.HasPrefix(line, "//") {
line = strings.TrimPrefix(line, "//")
line = strings.Trim(line, " ")
line = "# " + line
}
parsedSection.Comments = append(parsedSection.Comments, line)
continue
} else if isRequestLine(line) {
Expand All @@ -70,6 +75,10 @@ func parseSection(section string, document *Document) Section {
continue
} else if in_header {
if strings.Contains(line, ":") {
line = strings.Trim(line, " ")
splits := strings.Split(line, ":")
splits[0] = strings.ToLower(splits[0])
line = strings.Join(splits, ":")
parsedSection.Headers = append(parsedSection.Headers, line)
}
} else if in_body {
Expand Down

0 comments on commit 9bf45f5

Please sign in to comment.