$NetBSD: patch-aa,v 1.3 2001/04/24 09:00:26 abs Exp $

--- checkbot.pl.orig	Sun Apr 15 20:34:30 2001
+++ checkbot.pl
@@ -47,7 +47,7 @@
 
 checkbot [B<--debug>] [B<--help>] [B<--verbose>] [B<--url> start URL] 
          [B<--match> match string] [B<--exclude> exclude string]
-         [B<--proxy> proxy URL] [B<--internal-only>]
+         [B<--proxy> proxy URL] [B<--internal-only>] [B<--match-url-base>]
          [B<--ignore> ignore string] [B<-file> file name]
          [B<--style> style file URL]
          [B<--mailto> email address]
@@ -90,6 +90,11 @@
 
 The I<match string> can be a perl regular expression.
 
+=item --match-url-base
+
+This option causes checkbot to use the site component of each url when
+determining which pages are local.
+
 =item --exclude <exclude string>
 
 URLs matching the I<exclude string> are considered to be external,
@@ -262,7 +267,7 @@
 
   # Get command-line arguments
   use Getopt::Long;
-  my $result = GetOptions(qw(debug help verbose url=s match=s exclude|x=s file=s style=s ignore|z=s mailto|M=s note|N=s proxy=s internal-only sleep=i timeout=i interval=i dontwarn=s enable-virtual));
+  my $result = GetOptions(qw(debug help verbose url=s match=s exclude|x=s file=s style=s ignore|z=s mailto|M=s note|N=s proxy=s internal-only sleep=i timeout=i interval=i dontwarn=s enable-virtual match-url-base));
 
   # Handle arguments, some are mandatory, some have defaults
   &print_help if (($main::opt_help && $main::opt_help) 
@@ -273,6 +278,7 @@
   $main::opt_interval = 10800 unless defined $main::opt_interval and length $main::opt_interval;
   $main::opt_dontwarn = "xxx" unless defined $main::opt_dontwarn and length $main::opt_dontwarn;
   $main::opt_enable_virtual = 0 unless defined $main::opt_enable_virtual;
+  $main::opt_match_url_base = 0 unless defined $main::opt_match_url_base;
   # The default for opt_match will be set later, because we might want
   # to muck with opt_url first.
 
@@ -353,7 +359,11 @@
     my @matchurls;
     my $matchurl;
     foreach $matchurl (@starturls) {
-      push(@matchurls, quotemeta $matchurl);
+      $_ = $matchurl;
+      if ($main::opt_match_url_base && m#^(\w+://[^/]+/)#) {
+	$_ = $1;
+      }
+      push(@matchurls, quotemeta $_);
     }
     $main::opt_match = '(' . join('|', @matchurls) . ')';
     print STDERR "--match defaults to $main::opt_match\n" if $main::opt_verbose;
@@ -781,6 +791,7 @@
     print OUT "<tr><th align=left>--url</th><td>Start URL(s)</td><td>",
               join(',', @starturls), "</td></tr>\n";
     print OUT "<tr><th align=left>--match</th><td>Match regular expression</td><td>$main::opt_match</td></tr>\n";
+    print OUT "<tr><th align=left>--match-url-base</th><td>Match base of each url</td><td>$main::opt_match_url_base</td></tr>\n" if defined $main::opt_match_url_base;
     print OUT "<tr><th align=left>--exclude</th><td>Exclude regular expression</td><td>$main::opt_exclude</td></tr>\n" if defined $main::opt_exclude;
     print OUT "<tr><th align=left>--ignore</th><td>Ignore regular expression</td><td>$main::opt_ignore</td></tr>\n" if defined $main::opt_ignore;
     print OUT "<tr><th align=left>--dontwarn</th><td>Don't warn for these codes</td><td>$main::opt_dontwarn</td></tr>\n" if $main::opt_dontwarn ne 'xxx';
@@ -1154,6 +1165,7 @@
   print "  --interval seconds Maximum time interval between updates (default 10800)\n";
   print "  --dontwarn codes   Do not write warnings for these HTTP response codes\n";
   print "  --enable-virtual   Use only virtual names, not IP numbers for servers\n";
+  print "  --match-url-base   Use the site part of the url in --match\n";
   print "\n";
   print "Options --match, --exclude, and --ignore can take a perl regular expression\nas their argument\n\n";
   print "Use 'perldoc checkbot' for more verbose documentation.\n\n";
