Skip to content

Commit

Permalink
Fix for explicit http link
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Jun 30, 2021
1 parent 85bb2d3 commit caf2346
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/rdoc/markup/to_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ def gen_url url, text
url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
"<img src=\"#{url}\" />"
else
if scheme != 'link' and %r%\A([./]*+)(.*?\.)(rb|rdoc|md)(?=\z|#)%i =~ url
url = "#$1#{$2.tr('.', '_')}#$3.html#{$'}"
if scheme != 'link' and %r%\A((?!https?:).*/)([^/]+)\.(rb|rdoc|md)(?=\z|#)%i =~ url
url = "#$1#{$2.tr('.', '_')}_#$3.html#$'"
end

text = text.sub %r%^#{scheme}:/*%i, ''
Expand Down
12 changes: 6 additions & 6 deletions test/rdoc/test_rdoc_markup_to_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -741,33 +741,33 @@ def test_gen_url_ssl_image_url
def test_gen_url_rdoc_file
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>',
assert_equal '<a href="../ex.doc/example_rdoc.html">example</a>',
@to.gen_url('../ex.doc/example.rdoc', 'example')
assert_equal '<a href="doc/example_rdoc.html#label-one">example</a>',
@to.gen_url('doc/example.rdoc#label-one', 'example')
assert_equal '<a href="../ex_doc/example_rdoc.html#label-two">example</a>',
assert_equal '<a href="../ex.doc/example_rdoc.html#label-two">example</a>',
@to.gen_url('../ex.doc/example.rdoc#label-two', 'example')
end

def test_gen_url_md_file
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>',
assert_equal '<a href="../ex.doc/example_md.html">example</a>',
@to.gen_url('../ex.doc/example.md', 'example')
assert_equal '<a href="doc/example_md.html#label-one">example</a>',
@to.gen_url('doc/example.md#label-one', 'example')
assert_equal '<a href="../ex_doc/example_md.html#label-two">example</a>',
assert_equal '<a href="../ex.doc/example_md.html#label-two">example</a>',
@to.gen_url('../ex.doc/example.md#label-two', 'example')
end

def test_gen_url_rb_file
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>',
assert_equal '<a href="../ex.doc/example_rb.html">example</a>',
@to.gen_url('../ex.doc/example.rb', 'example')
assert_equal '<a href="doc/example_rb.html#label-one">example</a>',
@to.gen_url('doc/example.rb#label-one', 'example')
assert_equal '<a href="../ex_doc/example_rb.html#label-two">example</a>',
assert_equal '<a href="../ex.doc/example_rb.html#label-two">example</a>',
@to.gen_url('../ex.doc/example.rb#label-two', 'example')
end

Expand Down

0 comments on commit caf2346

Please sign in to comment.