summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRuss Allbery <rra@cpan.org>2021-09-11 18:52:35 -0700
committerRuss Allbery <rra@cpan.org>2021-09-11 18:52:35 -0700
commitae6d48059c2fd4a2722725fcbabcf73accaff75b (patch)
treea0abc9826a830b0618e9877d52296fb838f6a06e /lib
parent835e49480b6fab5a15579ece8b18b9cbcbe1dfd2 (diff)
Detect duplicate .sitemap entries
I had several duplicate .sitemap entries, which created bizarre problems trying to construct relative links. Detect those and abort when they are seen.
Diffstat (limited to 'lib')
-rw-r--r--lib/App/DocKnot/Spin/Sitemap.pm7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/App/DocKnot/Spin/Sitemap.pm b/lib/App/DocKnot/Spin/Sitemap.pm
index f8dfcd1..ee2d4d2 100644
--- a/lib/App/DocKnot/Spin/Sitemap.pm
+++ b/lib/App/DocKnot/Spin/Sitemap.pm
@@ -38,6 +38,7 @@ use List::SomeUtils qw(pairwise);
# Text exception on file parsing errors
sub _read_data {
my ($self, $path) = @_;
+ my %seen;
# @indents holds a stack of indentation levels to detect indentation
# changes that translate into page structure. Each element in the stack
@@ -71,6 +72,12 @@ sub _read_data {
die "invalid line $. in $path\n";
}
+ # Error on duplicate lines.
+ if ($seen{$url}) {
+ die "duplicate entry for $url in $path (line $.)\n";
+ }
+ $seen{$url} = 1;
+
# Open or close indentation levels.
my $indent = length($spaces);
if (!@indents || $indent > $indents[-1]->[0]) {