From adacfcf30b67462627457c6bc69d9c74ff72238a Mon Sep 17 00:00:00 2001
From: IKEDA Sho <suicaicoca@gmail.com>
Date: Wed, 17 May 2023 18:58:04 +0900
Subject: [PATCH] fix(cpanfile): support version ranges which are not
 v-prefixed (#22259)

---
 lib/modules/manager/cpanfile/extract.spec.ts | 37 ++++++++++++++++++++
 lib/modules/manager/cpanfile/parser.ts       |  2 +-
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/lib/modules/manager/cpanfile/extract.spec.ts b/lib/modules/manager/cpanfile/extract.spec.ts
index 5235cf3a59..29d0042c3b 100644
--- a/lib/modules/manager/cpanfile/extract.spec.ts
+++ b/lib/modules/manager/cpanfile/extract.spec.ts
@@ -44,6 +44,13 @@ describe('modules/manager/cpanfile/extract', () => {
             requires 'URI', '1.59';
             requires 'HTTP::Tiny', 0.034;
             requires "Capture::Tiny" => "0";
+
+            requires 'A', '== 1.1';
+            requires 'AA', '== v1.1';
+            requires 'B', '>= 1.2';
+            requires 'BB', '>= v1.2';
+            requires 'C', '> 1.3';
+            requires 'CC', '> v1.3';
           `,
           'cpanfile'
         )
@@ -69,6 +76,36 @@ describe('modules/manager/cpanfile/extract', () => {
             depName: 'Capture::Tiny',
             currentValue: '0',
           },
+          {
+            datasource: 'cpan',
+            depName: 'A',
+            currentValue: '1.1',
+          },
+          {
+            datasource: 'cpan',
+            depName: 'AA',
+            currentValue: '1.1',
+          },
+          {
+            datasource: 'cpan',
+            depName: 'B',
+            currentValue: '1.2',
+          },
+          {
+            datasource: 'cpan',
+            depName: 'BB',
+            currentValue: '1.2',
+          },
+          {
+            datasource: 'cpan',
+            depName: 'C',
+            currentValue: '1.3',
+          },
+          {
+            datasource: 'cpan',
+            depName: 'CC',
+            currentValue: '1.3',
+          },
         ],
       });
     });
diff --git a/lib/modules/manager/cpanfile/parser.ts b/lib/modules/manager/cpanfile/parser.ts
index da90144217..cf2286eaa7 100644
--- a/lib/modules/manager/cpanfile/parser.ts
+++ b/lib/modules/manager/cpanfile/parser.ts
@@ -69,7 +69,7 @@ const moduleMatch = q
     q.alt<Ctx>(q.op(','), q.op('=>')).alt(
       q.num<Ctx>((ctx, { value: currentValue }) => ({ ...ctx, currentValue })),
       q.str<Ctx>((ctx, { value }) => {
-        const currentValue = value.replace(/^(?:\s*(?:==|>=|>))?\s*v/, '');
+        const currentValue = value.replace(/^(?:\s*(?:==|>=|>))?\s*v?/, '');
         return { ...ctx, currentValue };
       })
     )
-- 
GitLab