Skip to content

Commit caf2346

Browse files
committed
Fix for explicit http link
1 parent 85bb2d3 commit caf2346

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/rdoc/markup/to_html.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ def gen_url url, text
357357
url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
358358
"<img src=\"#{url}\" />"
359359
else
360-
if scheme != 'link' and %r%\A([./]*+)(.*?\.)(rb|rdoc|md)(?=\z|#)%i =~ url
361-
url = "#$1#{$2.tr('.', '_')}#$3.html#{$'}"
360+
if scheme != 'link' and %r%\A((?!https?:).*/)([^/]+)\.(rb|rdoc|md)(?=\z|#)%i =~ url
361+
url = "#$1#{$2.tr('.', '_')}_#$3.html#$'"
362362
end
363363

364364
text = text.sub %r%^#{scheme}:/*%i, ''

test/rdoc/test_rdoc_markup_to_html.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -741,33 +741,33 @@ def test_gen_url_ssl_image_url
741741
def test_gen_url_rdoc_file
742742
assert_equal '<a href="doc/example_rdoc.html">example</a>',
743743
@to.gen_url('doc/example.rdoc', 'example')
744-
assert_equal '<a href="../ex_doc/example_rdoc.html">example</a>',
744+
assert_equal '<a href="../ex.doc/example_rdoc.html">example</a>',
745745
@to.gen_url('../ex.doc/example.rdoc', 'example')
746746
assert_equal '<a href="doc/example_rdoc.html#label-one">example</a>',
747747
@to.gen_url('doc/example.rdoc#label-one', 'example')
748-
assert_equal '<a href="../ex_doc/example_rdoc.html#label-two">example</a>',
748+
assert_equal '<a href="../ex.doc/example_rdoc.html#label-two">example</a>',
749749
@to.gen_url('../ex.doc/example.rdoc#label-two', 'example')
750750
end
751751

752752
def test_gen_url_md_file
753753
assert_equal '<a href="doc/example_md.html">example</a>',
754754
@to.gen_url('doc/example.md', 'example')
755-
assert_equal '<a href="../ex_doc/example_md.html">example</a>',
755+
assert_equal '<a href="../ex.doc/example_md.html">example</a>',
756756
@to.gen_url('../ex.doc/example.md', 'example')
757757
assert_equal '<a href="doc/example_md.html#label-one">example</a>',
758758
@to.gen_url('doc/example.md#label-one', 'example')
759-
assert_equal '<a href="../ex_doc/example_md.html#label-two">example</a>',
759+
assert_equal '<a href="../ex.doc/example_md.html#label-two">example</a>',
760760
@to.gen_url('../ex.doc/example.md#label-two', 'example')
761761
end
762762

763763
def test_gen_url_rb_file
764764
assert_equal '<a href="doc/example_rb.html">example</a>',
765765
@to.gen_url('doc/example.rb', 'example')
766-
assert_equal '<a href="../ex_doc/example_rb.html">example</a>',
766+
assert_equal '<a href="../ex.doc/example_rb.html">example</a>',
767767
@to.gen_url('../ex.doc/example.rb', 'example')
768768
assert_equal '<a href="doc/example_rb.html#label-one">example</a>',
769769
@to.gen_url('doc/example.rb#label-one', 'example')
770-
assert_equal '<a href="../ex_doc/example_rb.html#label-two">example</a>',
770+
assert_equal '<a href="../ex.doc/example_rb.html#label-two">example</a>',
771771
@to.gen_url('../ex.doc/example.rb#label-two', 'example')
772772
end
773773

0 commit comments

Comments
 (0)