Skip to content

Commit 68d459e

Browse files
authored
adding if to prevent panic due to regex (#84)
1 parent da3994a commit 68d459e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/TibiaCharactersCharacterV3.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,17 @@ func TibiaCharactersCharacterV3Impl(BoxContentHTML string) CharacterResponse {
268268
// Removing line breaks
269269
CharacterListHTML = TibiadataHTMLRemoveLinebreaksV3(CharacterListHTML)
270270

271-
subma1 := accountBadgesRegex.FindAllStringSubmatch(CharacterListHTML, -1)
271+
// prevent failure of regex that parses account badges
272+
if CharacterListHTML != "There are no account badges set to be displayed for this character." {
272273

273-
AccountBadgesData = append(AccountBadgesData, AccountBadges{
274-
Name: subma1[0][1],
275-
IconURL: subma1[0][3],
276-
Description: subma1[0][2],
277-
})
274+
subma1 := accountBadgesRegex.FindAllStringSubmatch(CharacterListHTML, -1)
275+
276+
AccountBadgesData = append(AccountBadgesData, AccountBadges{
277+
Name: subma1[0][1],
278+
IconURL: subma1[0][3],
279+
Description: subma1[0][2],
280+
})
281+
}
278282
})
279283
case "Account Achievements":
280284
// Running query over each tr in list

0 commit comments

Comments
 (0)