Fix escaping issue

The way file URLs are handled changed a bit in coursier...
This commit is contained in:
Alexandre Archambault 2020-11-18 17:48:17 +01:00
parent 84d54e5278
commit 6b597b3f79
1 changed files with 10 additions and 2 deletions

View File

@ -1,10 +1,11 @@
package lmcoursier.internal
import coursier.ivy.IvyRepository
import java.net.MalformedURLException
import java.nio.file.Paths
import coursier.cache.CacheUrl
import coursier.core.{Authentication, Repository}
import coursier.ivy.IvyRepository
import coursier.maven.MavenRepository
import org.apache.ivy.plugins.resolver.IBiblioResolver
import sbt.librarymanagement.{Configuration => _, MavenRepository => _, _}
@ -54,7 +55,14 @@ object Resolvers {
// this handles whitespace in path
private def pathToUriString(path: String): String = {
"file://" + path.replaceAllLiterally(" ", "%20")
val stopAtIdx = path.indexWhere(c => c == '[' || c == '$' || c == '(')
if (stopAtIdx > 0) {
val (pathPart, patternPart) = path.splitAt(stopAtIdx)
Paths.get(pathPart).toUri.toASCIIString + patternPart
} else if (stopAtIdx == 0)
"file://" + path
else
Paths.get(path).toUri.toASCIIString
}
def repository(