Skip to content

Commit f8490cd

Browse files
nnobelissschuberth
authored andcommitted
fix(bazel): Handle empty integrity in source.json
This prevents an `IndexOutOfBoundsException` when the integrity property is blank. Signed-off-by: Nicolas Nobelis <[email protected]>
1 parent f0965d2 commit f8490cd

File tree

1 file changed

+10
-7
lines changed
  • plugins/package-managers/bazel/src/main/kotlin

1 file changed

+10
-7
lines changed

plugins/package-managers/bazel/src/main/kotlin/Bazel.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -703,13 +703,16 @@ private fun ModuleMetadata.toVcsInfo() =
703703
private fun ModuleSourceInfo.toRemoteArtifact(): RemoteArtifact? =
704704
when (this) {
705705
is ArchiveSourceInfo -> {
706-
val (algo, b64digest) = integrity.split('-', limit = 2)
707-
val digest = Base64.decode(b64digest).toHexString()
708-
709-
val hash = Hash(
710-
value = digest,
711-
algorithm = HashAlgorithm.fromString(algo)
712-
)
706+
val hash = if (integrity.isNotEmpty()) {
707+
val (algo, b64digest) = integrity.split('-', limit = 2)
708+
val digest = Base64.decode(b64digest).toHexString()
709+
Hash(
710+
value = digest,
711+
algorithm = HashAlgorithm.fromString(algo)
712+
)
713+
} else {
714+
Hash.NONE
715+
}
713716

714717
RemoteArtifact(url = url.toString(), hash = hash)
715718
}

0 commit comments

Comments
 (0)