Skip to content

Commit 107ed9c

Browse files
committed
make sure no regex error used
1 parent e5f3f60 commit 107ed9c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

slack.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ func Slack(markdown string, options ...SlackConvertOptions) string {
3939
startOfPattern := `(?P<THE_START_OF_MATCH>^|[\s\[\(])`
4040
endOfPattern := `(?P<THE_END_OF_MATCH>$|[\s:\]\),.!])`
4141
for pattern, replace := range opt.CustomRefPatterns {
42-
re = regexp.MustCompile(fmt.Sprintf(`%s%s%s`, startOfPattern, pattern, endOfPattern))
42+
re, err := regexp.Compile(fmt.Sprintf(`%s%s%s`, startOfPattern, pattern, endOfPattern))
43+
if err != nil {
44+
println("ERROR_USING_CustomRefPatterns: " + err.Error())
45+
continue
46+
}
4347
markdown = re.ReplaceAllString(markdown, fmt.Sprintf(`${THE_START_OF_MATCH}%s${THE_END_OF_MATCH}`, replace))
4448
}
4549
}

0 commit comments

Comments
 (0)