Skip to content

Commit

Permalink
Merge pull request #341 from xuwei-k/java-net-URL-constructor
Browse files Browse the repository at this point in the history
avoid deprecated `java.net.URL` constructor
  • Loading branch information
eed3si9n authored Mar 25, 2023
2 parents f035146 + 097c9a0 commit bcfb7bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions io/src/main/scala/sbt/io/IO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,16 @@ object IO {
case "jar" =>
val path = url.getPath
val end = path.indexOf('!')
new URL(
new URI(
if (end == -1) path
else path.substring(0, end)
)
).toURL
case "jrt" =>
val path = url.getPath
val end = path.indexOf('/', 1)
new URL(
"jrt",
null,
if (end == -1) path
else path.substring(0, end)
)
new URI(
s"jrt://${if (end == -1) path else path.substring(0, end)}"
).toURL
case _ => url
}
)
Expand Down
2 changes: 1 addition & 1 deletion io/src/main/scala/sbt/io/syntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object syntax extends IOSyntax0 {

def uri(s: String): URI = new URI(s)
def file(s: String): File = new File(s)
def url(s: String): URL = new URL(s)
def url(s: String): URL = uri(s).toURL

implicit def fileToRichFile(file: File): RichFile = new RichFile(file)
implicit def filesToFinder(cc: Traversable[File]): PathFinder = PathFinder.strict(cc)
Expand Down

0 comments on commit bcfb7bb

Please sign in to comment.