mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Replace File.basename in URL#relative_path_to because it doesn't handle special characters in URLs well
This commit is contained in:
parent
ceccfc0951
commit
034ecfae72
2 changed files with 9 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue