Subject: | VISA regex bug - patch |
Line 224 of CreditCard.pm has the RE:
/^4[\dx]{12-18}$/o
The "-" should be a ",". Please find attached a patch with fix and test.
Subject: | 0001-test-fix-RE-challenge.patch |
From bdbf41140ddec6b1f2796ccd2fdab4005dfd7ddc Mon Sep 17 00:00:00 2001
From: Ed <mohawk2@users.noreply.github.com>
Date: Mon, 8 Feb 2016 14:13:43 +0000
Subject: [PATCH] test, fix RE "challenge"
---
CreditCard.pm | 2 +-
t/test.t | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CreditCard.pm b/CreditCard.pm
index ea12fee..f96c853 100644
--- a/CreditCard.pm
+++ b/CreditCard.pm
@@ -221,7 +221,7 @@ sub cardtype {
|| $number =~ /^564182[\dx]{10}([\dx]{2,3})?$/o
|| $number =~ /^6(3(33[0-4][0-9])|759[0-9]{2})[\dx]{10}([\dx]{2,3})?$/o;
#redunant with above, catch 49* that's not Switch
- return "VISA card" if $number =~ /^4[\dx]{12-18}$/o;
+ return "VISA card" if $number =~ /^4[\dx]{12,18}$/o;
#return "Diner's Club/Carte Blanche"
# if $number =~ /^3(0[0-59]|[68][\dx])[\dx]{11}$/o;
diff --git a/t/test.t b/t/test.t
index a885a48..5a4cdec 100644
--- a/t/test.t
+++ b/t/test.t
@@ -15,6 +15,7 @@ sub test_card_identification {
'5512345678901234' => 'MasterCard',
'2512345678901234' => 'MasterCard',
'4123456789012' => 'VISA card',
+ '4929492492497' => 'VISA card',
'4512345678901234' => 'VISA card',
'341234567890123' => 'American Express card',
'371234567890123' => 'American Express card',
--
1.9.1