Fixing duplicate chapter issue and adding unit test (#1221)

* Fixing duplicate chapter issue and adding unit test

* Update test name
This commit is contained in:
Robbie Davis 2022-04-18 15:57:31 -04:00 committed by GitHub
parent 8a78b8c746
commit 03ab44d50a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 6 deletions

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using API.Entities;
using API.Parser;
@ -28,8 +28,8 @@ namespace API.Extensions
{
var specialTreatment = info.IsSpecialInfo();
return specialTreatment
? chapters.SingleOrDefault(c => c.Range == info.Filename || (c.Files.Select(f => f.FilePath).Contains(info.FullFilePath)))
: chapters.SingleOrDefault(c => c.Range == info.Chapters);
? chapters.FirstOrDefault(c => c.Range == info.Filename || (c.Files.Select(f => f.FilePath).Contains(info.FullFilePath)))
: chapters.FirstOrDefault(c => c.Range == info.Chapters);
}
}
}
}