Make version parsing robust to leading or trailing spaces (#355)

This commit is contained in:
Erem Boto 2016-09-30 11:21:38 -07:00
parent 8369bacbc1
commit 50f38725d8
1 changed files with 3 additions and 2 deletions

View File

@ -6,8 +6,9 @@ import coursier.core.compatibility._
object Parse {
def version(s: String): Option[Version] = {
if (s.isEmpty || s.exists(c => c != '.' && c != '-' && c != '_' && !c.letterOrDigit)) None
else Some(Version(s))
val trimmed = s.trim
if (trimmed.isEmpty || trimmed.exists(c => c != '.' && c != '-' && c != '_' && !c.letterOrDigit)) None
else Some(Version(trimmed))
}
def ivyLatestSubRevisionInterval(s: String): Option[VersionInterval] =