Skip to content

Commit

Permalink
Allow local_module_url_prefix to be ''
Browse files Browse the repository at this point in the history
closes gh-17
  • Loading branch information
rwstauner committed Oct 6, 2019
1 parent 0e80997 commit f30fc2f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Revision history for Perl extension {{$dist->name}}

{{$NEXT}}

- Allow local_module_url_prefix to be '' [rt-129865].

3.101 2018-08-06T14:32:38Z

- Ensure local_module_url_prefix defaults to current perldoc_url_prefix.
Expand Down
12 changes: 9 additions & 3 deletions lib/Pod/Markdown.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1224,16 +1224,22 @@ and L</markdown_fragment_format> is used (which can be customized).
sub format_perldoc_url {
my ($self, $name, $section) = @_;

my $url_prefix = defined($name)
my $url_prefix = $self->perldoc_url_prefix;
if (
defined($name)
&& $self->is_local_module($name)
&& $self->local_module_url_prefix
|| $self->perldoc_url_prefix;
&& defined($self->local_module_url_prefix)
) {
$url_prefix = $self->local_module_url_prefix;
}

my $url = '';

# If the link is to another module (external link).
if ($name) {
$url = $url_prefix . $name;
# If there's no prefix don't let the name to be interpreted as an ipv6 address.
$url =~ s/::/%3a%3a/g if $url_prefix eq '';
}

# See https://rt.cpan.org/Ticket/Display.html?id=57776
Expand Down
4 changes: 4 additions & 0 deletions t/links.t
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ my @tests = (
'NonLocal* with custom RE');
test_link($p, q<Local::Foo>, qq^[Local::Foo](perldoc://Local::Foo)^,
'even Local::* uses perldoc when custom re does not match');

$p = {local_module_url_prefix => ''};
test_link($p, q<Local::Foo::Bar>, qq^[Local::Foo::Bar](Local%3a%3aFoo%3a%3aBar)^,
'local module with empty prefix');
}

# Most of these examples were internal links
Expand Down

0 comments on commit f30fc2f

Please sign in to comment.