From 98f1a6c02085291c86bc3ba3e8c27164e9fc4be0 Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Tue, 2 May 2023 18:28:15 +0200 Subject: [PATCH] Avoding empty lastmod tags. --- lib/BurguillosInfo/Controller/Sitemap.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/BurguillosInfo/Controller/Sitemap.pm b/lib/BurguillosInfo/Controller/Sitemap.pm index f44a242..65888e8 100644 --- a/lib/BurguillosInfo/Controller/Sitemap.pm +++ b/lib/BurguillosInfo/Controller/Sitemap.pm @@ -52,11 +52,13 @@ sub _append_category_dom ( $self, $dom, $category_key, $categories ) { my $final_date_last_modification_category = _compare_dates_return_most_recent( $date_publish_category, $date_last_modification_category ); - my $last_modification_tag = - Mojo::DOM->new_tag( lastmod => $final_date_last_modification_category ); + if (defined $final_date_last_modification_category) { + my $last_modification_tag = + Mojo::DOM->new_tag( lastmod => $final_date_last_modification_category ); + $url->child_nodes->first->append_content($last_modification_tag); + } my $priority_tag = Mojo::DOM->new_tag( priority => 0.6 ); $url->child_nodes->first->append_content($location_tag); - $url->child_nodes->first->append_content($last_modification_tag); $url->child_nodes->first->append_content($priority_tag); $dom->child_nodes->first->append_content($url);