- local $_ = $1, $p = $2, ((($b) = /([\.,!\?\(\)\[\]]+$)/) ? s/// :
- undef), s/&(?!\x23?\w+;)/&/g, s/\"/"/g, $c =
- ($p eq 'www.' || $p eq 'WWW.' ? "http://$_" : $_),
- qq{<a href="$c" target="_blank">$_</a>$b}
+ local $_ = $1;
+ my $scheme = $2;
+ s/// if (my $trailing) = /([\.,!\?\(\)\[\]]+$)/;
+ s/&(?!\x23?\w+;)/&/g;
+ s/\"/"/g;
+ my $href = ($scheme =~ /www\./i ? "http://$_" : $_);
+ qq{<a href="$href" target="_blank">$_</a>$trailing};