Fixed matchID transformation to deal with textSigles having dashes
Change-Id: I0bba96ffc45d34551146cc59a7db4d6ed3c39210
diff --git a/Changes b/Changes
index 08878a3..b247f4b 100755
--- a/Changes
+++ b/Changes
@@ -22,6 +22,8 @@
- Added pipe object to implement KoralPipes.
- Separated "service" from "widget" plugin embeddings.
- Implemented preliminary host->plugin communication.
+ - Fixed matchID transformation to deal with textSigles
+ having dashes.
0.36 2019-09-19
- Rename all cookies to be independent
diff --git a/lib/Kalamar/Controller/Search.pm b/lib/Kalamar/Controller/Search.pm
index e69f8f0..c29a97b 100644
--- a/lib/Kalamar/Controller/Search.pm
+++ b/lib/Kalamar/Controller/Search.pm
@@ -3,6 +3,7 @@
use Mojo::Collection 'c';
use Mojo::ByteStream 'b';
use Mojo::Util qw/quote/;
+use Mojo::JSON;
use POSIX 'ceil';
has items_per_page => 25;
@@ -488,8 +489,8 @@
# Legacy match id
if ($match->{matchID}) {
- $match->{matchID} =~ s/^match\-(?:[^!]+!|[^_]+_)[^\.]+?\.[^-]+?-// or
- $match->{matchID} =~ s!^match\-(?:[^\/]+\/){2}[^-]+?-!!;
+ $match->{matchID} =~ s/^match\-(?:[^!]+!|[^_]+_)[^\.]+?\..+?-([pc]\d)/$1/ or
+ $match->{matchID} =~ s!^match\-(?:[^\/]+\/){2}.+?-([pc]\d)!$1!;
};
return unless $match->{textSigle};
@@ -510,8 +511,6 @@
__END__
-__END__
-
=pod
=encoding utf8
diff --git a/t/query.t b/t/query.t
index 3252bac..035560d 100644
--- a/t/query.t
+++ b/t/query.t
@@ -2,6 +2,7 @@
use Test::Mojo;
use Test::More;
use Mojo::File qw/path/;
+use Kalamar::Controller::Search;
#####################
@@ -250,5 +251,16 @@
;
+
+my $match = {
+ matchID => 'match-FOLK/00070-SE-01/T-04-p5441-5442',
+ textSigle => 'FOLK/00070-SE-01/T-04'
+};
+
+$match = Kalamar::Controller::Search::_map_match($match);
+
+is($match->{matchID}, 'p5441-5442');
+
+
done_testing;
__END__