summaryrefslogtreecommitdiff
path: root/lib/VNDBUtil.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-04-06 17:01:14 +0200
committerYorhel <git@yorhel.nl>2020-04-06 17:01:17 +0200
commit91c5ca72e9c90c5a60f71e53a68c980094a59da8 (patch)
tree18fd78ab58ae08440ed9e2f70335851c51093a9e /lib/VNDBUtil.pm
parent6b04feb79ced4571150a64c19fd70539aa4596fb (diff)
Release::Edit: Consider GTIN code as a string for validation/editing
Problem is that the 'uint' validation does not allow leading zeros, which are very valid as part of GTIN codes, thus resulting in an error when validating a normalized GTIN code.
Diffstat (limited to 'lib/VNDBUtil.pm')
-rw-r--r--lib/VNDBUtil.pm1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/VNDBUtil.pm b/lib/VNDBUtil.pm
index 5d7850bc..80d45fc6 100644
--- a/lib/VNDBUtil.pm
+++ b/lib/VNDBUtil.pm
@@ -23,6 +23,7 @@ sub shorten {
# Also 'normalizes' the first argument in place
sub gtintype {
$_[0] =~ s/[^\d]+//g;
+ $_[0] =~ s/^0+//;
return undef if $_[0] !~ /^[0-9]{10,13}$/; # I've yet to see a UPC code shorter than 10 digits assigned to a game
$_[0] = ('0'x(12-length $_[0])) . $_[0] if length($_[0]) < 12; # pad with zeros to GTIN-12
my $c = shift;