Skip to content

Commit 41bc7a5

Browse files
Merge pull request #64 from nullinside-development-group/feature/IndexOutOfRange
fix: Index out of range exception in Cheap Viewers rule
2 parents e0966b3 + ba8b81a commit 41bc7a5

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

src/Nullinside.Api.TwitchBot.Tests/ChatRules/BestCheapViewersTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class BestCheapViewersTests : AChatRuleUnitTestBase<BestCheapViewers> {
1515
/// </summary>
1616
/// <param name="badString">The string that should fail.</param>
1717
[Test]
18+
[TestCase("C\u032dheap viewe\u034crs on\u0306 vwrpro.ru @8v2JcQFL")]
19+
[TestCase("Ch\u031ae\u0345ap viewers on *** @STGPMoLg")]
1820
[TestCase("Best\u036e vie\u0350wers \u0337on ***")]
1921
[TestCase("Best viewers on ***")]
2022
[TestCase("Best viewers on ***")]

src/Nullinside.Api.TwitchBot.Tests/ChatRules/DoghypeTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class DogehypeTests : AChatRuleUnitTestBase<Dogehype> {
1515
/// </summary>
1616
/// <param name="badString">The string that should fail.</param>
1717
[Test]
18+
[TestCase("Visit dogehype dot com today and effortlessly boost your Twitch rankings! @opAzPMVt")]
1819
[TestCase("Visit dogehype dot com and watch your channel grow today! @5MGxTnYl")]
1920
[TestCase("Visit dogehype dot com today and climb the Twitch rankings with ease! Whether you're just starting out or looking to take your stream to the next level, DogeHype has the tools you need to succeed. @gqznceDC")]
2021
[TestCase("Visit dogehype .biz com today and climb the Twitch rankings with ease! Whether you're just starting out or looking to take your stream to the next level, DogeHype has the tools you need to succeed. @Axxq7ntz")]

src/Nullinside.Api.TwitchBot/ChatRules/BestCheapViewers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public override async Task<bool> Handle(string channelId, ITwitchApiProxy botPro
4747
int offset = 0;
4848
for (int i = 0; i < expected.Length; i++) {
4949
// If this is a normal character it should be in the correct position.
50-
if (normalized[i + offset] == expected[i]) {
50+
if (i + offset < normalized.Length && normalized[i + offset] == expected[i]) {
5151
++matches;
5252
}
5353
// If this is an accent mark then the next character should match and the whole string we're evalutating

0 commit comments

Comments
 (0)