diff --git a/lexer_state.go b/lexer_state.go index b0b4d54..76c29f1 100644 --- a/lexer_state.go +++ b/lexer_state.go @@ -111,12 +111,13 @@ func descriptionDelimiterState(l *lexer) stateFunc { l.Emit(breakingChangeToken) } - l.Take(": ") + l.Next() - if l.Current() != ": " { + if l.Current() != ":" || l.Peek() != ' ' { l.Error(errDescMissingDelimiter) return nil } + l.Next() l.Emit(descDelimiterToken) diff --git a/parser_header_test.go b/parser_header_test.go index cc9c263..71757cf 100644 --- a/parser_header_test.go +++ b/parser_header_test.go @@ -17,6 +17,24 @@ func TestParseHeaderValid(t *testing.T) { "feat: description with body 1, \n\n2, 3 and 4?", "feat1234(@scope/scope1,scope2): description, \n\n body 1 2, 3 and 4?", "1245#feat1234(@scope/scope1,scope2): description, \n\n body 1 2, 3 and 4?", + "feat: description with colon at the end: mid:dle and :start of words", + "feat: description with gitmoji at the end :hammer:", + "feat: description with gitmoji in :hammer: the middle", + "feat: :hammer: description with gitmoji at the start", + "feat(scope): description with colon at the end: mid:dle and :start of words", + "feat(scope): description with gitmoji at the end :hammer:", + "feat(scope): description with gitmoji in :hammer: the middle", + "feat(scope): :hammer: description with gitmoji at the start", + "feat!: description with colon at the end: mid:dle and :start of words", + "feat!: description with gitmoji at the end :hammer:", + "feat!: description with gitmoji in :hammer: the middle", + "feat!: :hammer: description with gitmoji at the start", + "feat(scope)!: description with colon at the end: mid:dle and :start of words", + "feat(scope)!: description with gitmoji at the end :hammer:", + "feat(scope)!: description with gitmoji in :hammer: the middle", + "feat(scope)!: :hammer: description with gitmoji at the start", + `feat: : : A description`, + `feat: :: A description ::`, } p := New() @@ -52,6 +70,8 @@ func TestParseHeaderInvalid(t *testing.T) { `feat((`, `feat():`, `feat):`, + `feat:: A description`, + `feat:::: A description`, } p := New()