common: omit trailing slash from requestless canonical links
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 21 Feb 2024 21:48:42 +0000 (22:48 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Wed, 6 Mar 2024 00:50:13 +0000 (01:50 +0100)
common.inc.plp

index 8a13059a5c50c139cb1f698c5f463a29d17f4354..ee21f022748d60cb2ea20f7fda53d667950291fe 100644 (file)
@@ -157,7 +157,8 @@ sub Html {
 
        my ($file) = $ENV{SCRIPT_FILENAME} =~ m{ ([^/]+) \.plp$ }x;
 
-       if (my $url = $meta->{canonical} // "/$file/$Request") {
+       $meta->{canonical} //= "/$file" . ($Request ne '' && "/$Request");
+       if (my $url = $meta->{canonical}) {
                $url = "https://sheet.shiar.nl$url";
                push @{ $meta->{raw} }, qq(<link rel="canonical" href="$url" />);
        }