while ($offset < @$self) {
my $link = substr $self->[$offset], 0, $length;
if ($context) {
- {
+ if ($offset > $context - 1) {
# take a value slightly before the current offset
- my $before = $offset > $context ? $self->[$offset - $context] : '.';
+ my $before = $self->[$offset - $context - 1];
# see how much of it matches the current link
my $trim = 1;
for my $match (split //, $before) {