summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rdoc/markup/to_html.rb2
-rw-r--r--test/rdoc/test_rdoc_markup_to_html.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb
index f3dd96e157..d3bb8af835 100644
--- a/lib/rdoc/markup/to_html.rb
+++ b/lib/rdoc/markup/to_html.rb
@@ -357,7 +357,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
"<img src=\"#{url}\" />"
else
- if scheme != 'link' and %r%\A((?!https?:).*/)([^/]+)\.(rb|rdoc|md)(?=\z|#)%i =~ url
+ if scheme != 'link' and %r%\A((?!https?:)(?:[^/#]*/)*+)([^/#]+)\.(rb|rdoc|md)(?=\z|#)%i =~ url
url = "#$1#{$2.tr('.', '_')}_#$3.html#$'"
end
diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb
index aa36fb77c4..342cf71082 100644
--- a/test/rdoc/test_rdoc_markup_to_html.rb
+++ b/test/rdoc/test_rdoc_markup_to_html.rb
@@ -739,6 +739,8 @@ EXPECTED
end
def test_gen_url_rdoc_file
+ assert_equal '<a href="example_rdoc.html">example</a>',
+ @to.gen_url('example.rdoc', 'example')
assert_equal '<a href="doc/example_rdoc.html">example</a>',
@to.gen_url('doc/example.rdoc', 'example')
assert_equal '<a href="../ex.doc/example_rdoc.html">example</a>',
@@ -750,6 +752,8 @@ EXPECTED
end
def test_gen_url_md_file
+ assert_equal '<a href="example_md.html">example</a>',
+ @to.gen_url('example.md', 'example')
assert_equal '<a href="doc/example_md.html">example</a>',
@to.gen_url('doc/example.md', 'example')
assert_equal '<a href="../ex.doc/example_md.html">example</a>',
@@ -761,6 +765,8 @@ EXPECTED
end
def test_gen_url_rb_file
+ assert_equal '<a href="example_rb.html">example</a>',
+ @to.gen_url('example.rb', 'example')
assert_equal '<a href="doc/example_rb.html">example</a>',
@to.gen_url('doc/example.rb', 'example')
assert_equal '<a href="../ex.doc/example_rb.html">example</a>',