common: omit trailing slash from requestless canonical links
[sheet.git] / 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" />);
        }