Skip to content

Commit

Permalink
refactor: rename api
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Oct 7, 2021
1 parent 7c47737 commit 5e4238f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func splitToLines(text string) []string {
return strings.Split(strings.ReplaceAll(text, "\r\n", "\n"), "\n")
}

func (m Message) GetHeader() Header {
func (m Message) ParseHeader() Header {
headerMatchers := HEADER_PATTERN.FindStringSubmatch(m.Header)
revertHeaderMatchers := REVERT_HEADER_PATTERN.FindStringSubmatch(m.Header)
header := Header{}
Expand All @@ -63,7 +63,7 @@ func (m Message) GetHeader() Header {
return header
}

func (m Message) GetFooter() []Footer {
func (m Message) ParseFooter() []Footer {
footers := make([]Footer, 0)

for _, m := range m.Footer {
Expand Down Expand Up @@ -96,7 +96,7 @@ func (m Message) GetFooter() []Footer {
footers = append(footers, footer)
}

header := m.GetHeader()
header := m.ParseHeader()

if header.Type == "revert" {
matcher := REVERT_BODY_PATTERN.FindStringSubmatch(m.Body)
Expand All @@ -118,8 +118,8 @@ func (m Message) GetFooter() []Footer {
return footers
}

func (m Message) GetFooterField(tags ...string) *Footer {
footers := m.GetFooter()
func (m Message) GetFooterByField(tags ...string) *Footer {
footers := m.ParseFooter()

for _, tag := range tags {
for _, f := range footers {
Expand Down
4 changes: 2 additions & 2 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ app.use({})

assert.Equal(t, tt.want, msg)

assert.Equal(t, tt.header, msg.GetHeader())
assert.Equal(t, tt.footer, msg.GetFooter())
assert.Equal(t, tt.header, msg.ParseHeader())
assert.Equal(t, tt.footer, msg.ParseFooter())
})
}
}

0 comments on commit 5e4238f

Please sign in to comment.