Skip to content

Commit

Permalink
Merge pull request #3016 from Seetaramayya/fix-StringIndexOutOfBounds…
Browse files Browse the repository at this point in the history
…Exception

Fixed throwing StringIndexOutOfBoundsException
  • Loading branch information
fthomas committed Mar 24, 2023
2 parents 1ea3fd8 + 47796a2 commit 45feae5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object Substring {
def applyAll(replacements: List[Replacement])(source: String): String = {
var start = 0
val sb = new java.lang.StringBuilder(source.length)
replacements.sortBy(_.position.start).foreach { r =>
replacements.distinctBy(_.position.start).sortBy(_.position.start).foreach { r =>
val before = source.substring(start, r.position.start)
start = r.position.start + r.position.value.length
sb.append(before).append(r.replacement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,17 @@ class RewriteTest extends FunSuite {
runApplyUpdate(update, original, expected)
}

// https://github.com/scala-steward-org/scala-steward/pull/3016
test("artifact change with multiple artifactId cross names") {
val update = ("com.pauldijou".g % Nel.of(
("jwt-core", "jwt-core_2.12").a,
("jwt-core", "jwt-core_2.13").a
) % "5.0.0" %> "9.2.0").single.copy(newerGroupId = Some("com.github.jwt-scala".g))
val original = Map("build.sbt" -> """ "com.pauldijou" %% "jwt-core" % "5.0.0" """)
val expected = Map("build.sbt" -> """ "com.github.jwt-scala" %% "jwt-core" % "9.2.0" """)
runApplyUpdate(update, original, expected)
}

// https://github.com/scala-steward-org/scala-steward/pull/566
test("prevent exception: named capturing group is missing trailing '}'") {
val update =
Expand Down

0 comments on commit 45feae5

Please sign in to comment.