From f88a9097a4708e8c179eead4e67ee67f15fcdefe Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 15 May 2021 01:06:36 +0900 Subject: [PATCH] [ruby/rdoc] Fix for explicit http link https://github.com/ruby/rdoc/commit/caf234665c --- lib/rdoc/markup/to_html.rb | 4 ++-- test/rdoc/test_rdoc_markup_to_html.rb | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index 6a8ca8a2d7..f3dd96e157 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -357,8 +357,8 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then "" 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, '' diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb index f7887f081b..aa36fb77c4 100644 --- a/test/rdoc/test_rdoc_markup_to_html.rb +++ b/test/rdoc/test_rdoc_markup_to_html.rb @@ -741,33 +741,33 @@ EXPECTED def test_gen_url_rdoc_file assert_equal 'example', @to.gen_url('doc/example.rdoc', 'example') - assert_equal 'example', + assert_equal 'example', @to.gen_url('../ex.doc/example.rdoc', 'example') assert_equal 'example', @to.gen_url('doc/example.rdoc#label-one', 'example') - assert_equal 'example', + assert_equal 'example', @to.gen_url('../ex.doc/example.rdoc#label-two', 'example') end def test_gen_url_md_file assert_equal 'example', @to.gen_url('doc/example.md', 'example') - assert_equal 'example', + assert_equal 'example', @to.gen_url('../ex.doc/example.md', 'example') assert_equal 'example', @to.gen_url('doc/example.md#label-one', 'example') - assert_equal 'example', + assert_equal 'example', @to.gen_url('../ex.doc/example.md#label-two', 'example') end def test_gen_url_rb_file assert_equal 'example', @to.gen_url('doc/example.rb', 'example') - assert_equal 'example', + assert_equal 'example', @to.gen_url('../ex.doc/example.rb', 'example') assert_equal 'example', @to.gen_url('doc/example.rb#label-one', 'example') - assert_equal 'example', + assert_equal 'example', @to.gen_url('../ex.doc/example.rb#label-two', 'example') end