X-Git-Url: https://git.madduck.net/code/myrepos.git/blobdiff_plain/7cbacd59bf538bac9e5868a005be162b265e44d6..60545177be81428ab485ff3bc1eb93895194c683:/webcheckout?ds=sidebyside diff --git a/webcheckout b/webcheckout index 4841fee..6df790d 100755 --- a/webcheckout +++ b/webcheckout @@ -127,23 +127,26 @@ sub doit { sub better { my ($a, $b)=@_; - my $firstanon=$b; + my @anon; foreach my $r (@anon_urls) { if ($a->{href} =~ /$r/) { - $firstanon=$a; - last; + push @anon, $a; } elsif ($b->{href} =~ /$r/) { - $firstanon=$b; - last; + push @anon, $b; } } if ($want_auth) { - return $firstanon != $a; + # Whichever is authed is better. + return 1 if ! @anon || ! grep { $_ eq $a } @anon; + return 0 if ! grep { $_ eq $b } @anon; + # Neither is authed, so the better anon method wins. + return $anon[0] == $a; } else { - return $firstanon == $a; + # Better anon method wins. + return @anon && $anon[0] == $a; } }