@@ -, +, @@ GetMarcUrls --- C4/Biblio.pm | 1 + t/db_dependent/Biblio.t | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -2048,6 +2048,7 @@ sub GetMarcUrls { } my @urls = $field->subfield('u'); foreach my $url (@urls) { + $url =~ s/^\s+|\s+$//g; # trim my $marcurl; if ( $marcflavour eq 'MARC21' ) { my $s3 = $field->subfield('3'); --- a/t/db_dependent/Biblio.t +++ a/t/db_dependent/Biblio.t @@ -272,6 +272,17 @@ sub run_tests { is( ( $marcflavour eq 'UNIMARC' && @$a2 == @$a1 + 1 ) || ( $marcflavour ne 'UNIMARC' && @$a2 == @$a1 + 3 ), 1, 'Check the number of returned notes of GetMarcNotes' ); + + # test for GetMarcUrls + $marc_record->append_fields( + MARC::Field->new( '856', '', '', u => ' https://koha-community.org ' ), + MARC::Field->new( '856', '', '', u => 'koha-community.org' ), + ); + my $marcurl = GetMarcUrls( $marc_record, $marcflavour ); + is( @$marcurl, 2, 'GetMarcUrls returns two URLs' ); + like( $marcurl->[0]->{MARCURL}, qr/^https/, 'GetMarcUrls did not stumble over a preceding space' ); + ok( $marcflavour ne 'MARC21' || $marcurl->[1]->{MARCURL} =~ /^http:\/\//, + 'GetMarcUrls prefixed a MARC21 URL with http://' ); } sub get_title_field { @@ -326,19 +337,19 @@ sub create_issn_field { } subtest 'MARC21' => sub { - plan tests => 31; + plan tests => 34; run_tests('MARC21'); $dbh->rollback; }; subtest 'UNIMARC' => sub { - plan tests => 31; + plan tests => 34; run_tests('UNIMARC'); $dbh->rollback; }; subtest 'NORMARC' => sub { - plan tests => 31; + plan tests => 34; run_tests('NORMARC'); $dbh->rollback; }; --