Skip to content

Commit

Permalink
fix expression search date matching
Browse files Browse the repository at this point in the history
  • Loading branch information
rwst committed Mar 10, 2024
1 parent 31518c4 commit 46f8afd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class DateMatcherTest {
companion object {
val testData = listOf(
TestData("", "2002", true),
TestData("", "2002-01-04", true),
TestData("2002", "2002", true),
TestData("2000-2004", "2002", true),
TestData("1999", "2002", false),
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/org/reactome/lit_ball/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ class DateMatcher(filteredDate: String?) {

fun matches(publicationDate: String?): Boolean {
if (!initialized) return false
if (fromYear == -infinity && toYear == infinity) return true
publicationDate?.let { pDate ->
if (pDate.isBlank()) return true
if (pDate.length < 4 || pDate.any { !it.isDigit() })
return false
val pYear = pDate.slice(0..3).toInt()
Expand Down

0 comments on commit 46f8afd

Please sign in to comment.