diff --git a/lib/docs/core/url.rb b/lib/docs/core/url.rb index 62b474e1..b2eaf658 100644 --- a/lib/docs/core/url.rb +++ b/lib/docs/core/url.rb @@ -100,7 +100,7 @@ module Docs result << '/' if result != '.' end else - dest_dir.parent.relative_path_from(base_dir).join(::File.basename(dest)).to_s + dest_dir.parent.relative_path_from(base_dir).join(dest.split('/').last).to_s end end diff --git a/test/lib/docs/core/url_test.rb b/test/lib/docs/core/url_test.rb index 71464b9e..8dd187c5 100644 --- a/test/lib/docs/core/url_test.rb +++ b/test/lib/docs/core/url_test.rb @@ -394,6 +394,14 @@ class DocsUrlTest < MiniTest::Spec assert_equal 'file', url.relative_path_to('http://example.com/file?query#frag') end + it "returns 'some:file' with 'http://example.com/some:file'" do + assert_equal 'some:file', url.relative_path_to('http://example.com/some:file') + end + + it "returns 'some:file' with 'http://example.com/some:file?query#frag'" do + assert_equal 'some:file', url.relative_path_to('http://example.com/some:file?query#frag') + end + it "returns nil with '/file'" do assert_nil url.relative_path_to('/file') end