From 2d9d64d1bc644edc0672448d9293658b1ad29c98 Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Wed, 20 Jan 2021 13:10:20 +0400 Subject: [PATCH] fix(sbt): Parse dependency the more precise way (#8353) --- lib/manager/sbt/__fixtures__/sample.sbt | 2 ++ lib/manager/sbt/__snapshots__/extract.spec.ts.snap | 14 ++++++++++++++ lib/manager/sbt/extract.ts | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/manager/sbt/__fixtures__/sample.sbt b/lib/manager/sbt/__fixtures__/sample.sbt index a2f4e94dcd..9c82f1186c 100644 --- a/lib/manager/sbt/__fixtures__/sample.sbt +++ b/lib/manager/sbt/__fixtures__/sample.sbt @@ -33,3 +33,5 @@ resolvers ++= Seq( resolvers ++= Seq("Repo #5" at "https://example.com/repos/5/") addSbtPlugin("org.example" % "waldo" % "0.0.9") + +libraryDependencies += "org.example" % "fred" % "(,8.4.0]" diff --git a/lib/manager/sbt/__snapshots__/extract.spec.ts.snap b/lib/manager/sbt/__snapshots__/extract.spec.ts.snap index 4c70a36242..770910ed1e 100644 --- a/lib/manager/sbt/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/sbt/__snapshots__/extract.spec.ts.snap @@ -239,6 +239,20 @@ Object { "https://dl.bintray.com/sbt/sbt-plugin-releases", ], }, + Object { + "currentValue": "(,8.4.0]", + "datasource": "sbt-package", + "depName": "org.example:fred", + "lookupName": "org.example:fred", + "registryUrls": Array [ + "https://repo.maven.apache.org/maven2", + "https://example.com/repos/1/", + "https://example.com/repos/2/", + "https://example.com/repos/3/", + "https://example.com/repos/4/", + "https://example.com/repos/5/", + ], + }, ], "packageFileVersion": "1.0", } diff --git a/lib/manager/sbt/extract.ts b/lib/manager/sbt/extract.ts index 6743b2e5d4..57f9a0a41d 100644 --- a/lib/manager/sbt/extract.ts +++ b/lib/manager/sbt/extract.ts @@ -125,7 +125,9 @@ function parseDepExpr( const tokens = expr .trim() - .replace(/[()]/g, '') + .split(/("[^"]*")/g) + .map((x) => (/"[^"]*"/.test(x) ? x : x.replace(/[()]+/g, ''))) + .join('') .split(/\s*(%%?)\s*|\s*classifier\s*/); const [