Skip to content

Commit

Permalink
fix encoding of spaces in metadata source URL
Browse files Browse the repository at this point in the history
  • Loading branch information
memo33 committed Dec 19, 2024
1 parent 6c61b37 commit 2145bdb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog

## [Unreleased]
### Fixed
- an issue where building a channel with file names containing spaces failed


## [0.5.0] - 2024-12-14
Expand Down
5 changes: 4 additions & 1 deletion src/main/scala/sc4pac/ChannelUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ object ChannelUtil {
)
}

private[sc4pac] def resolveMetadataSourceUrl(baseUri: java.net.URI, path: os.SubPath): java.net.URI =
baseUri.resolve(os.root.toNIO.toUri.relativize((os.root / path).toNIO.toUri))

case class YamlPackageData(
group: String,
name: String,
Expand All @@ -50,7 +53,7 @@ object ChannelUtil {
for {
baseUri <- channelInfo.metadataSourceUrl
path <- metadataSource
} yield baseUri.resolve(path.segments0.mkString("/")),
} yield resolveMetadataSourceUrl(baseUri, path),
channelLabel = channelInfo.channelLabel,
)}
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/scala/sc4pac/ChannelSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ url: dummy
).head._2
.map(_.orgName).toSet.shouldBe(Set("test:pkg1", "test:pkg2"))
}

"encode spaces in metadata source URL" in {
val baseUri = java.net.URI("https://github.com/memo33/sc4pac/blob/main/src/yaml/")
ChannelUtil.resolveMetadataSourceUrl(baseUri, os.SubPath("a b/c d.yaml"))
.toString.shouldBe(s"${baseUri}a%20b/c%20d.yaml")
}
}

}

0 comments on commit 2145bdb

Please sign in to comment.