added missing module import to C4::ILSDI::Utility
[koha.git] / C4 / Matcher.pm
index 645b2ad..c9a1e46 100644 (file)
@@ -18,6 +18,8 @@ package C4::Matcher;
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
+use warnings;
+
 use C4::Context;
 use MARC::Record;
 use C4::Search;
@@ -786,6 +788,11 @@ sub _get_match_keys {
                     }
                 }
                 $key = _normalize($key);
+                if ($component->{'length'}){
+                   if (length($key) > $component->{'length'}){
+                     $key = _normalize(substr($key,$component->{'offset'},$component->{'length'}));
+                   }
+                }
             }
             if ($i == 0) {
                 push @keys, $key if $key;
@@ -815,10 +822,12 @@ sub _parse_match_component {
 # FIXME - default normalizer
 sub _normalize {
     my $value = uc shift;
+    $value =~ s/[.;:,\]\[\)\(\/'"]//g;
     $value =~ s/^\s+//;
-    $value =~ s/^\s+$//;
+    #$value =~ s/^\s+$//;
+    $value =~ s/\s+$//;
     $value =~ s/\s+/ /g;
-    $value =~ s/[.;,\]\[\)\(\/"']//g;
+    #$value =~ s/[.;,\]\[\)\(\/"']//g;
     return $value;
 }