mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Handle unencoded spaces in link hrefs
This commit is contained in:
parent
ae7a5abd96
commit
63c77322d3
2 changed files with 7 additions and 0 deletions
|
@ -18,6 +18,8 @@ module Docs
|
|||
end
|
||||
|
||||
def normalize_url(str)
|
||||
str.strip!
|
||||
str.gsub!(' ', '%20')
|
||||
url = to_absolute_url(str)
|
||||
|
||||
while new_url = fix_url(url)
|
||||
|
|
|
@ -44,6 +44,11 @@ class NormalizeUrlsFilterTest < MiniTest::Spec
|
|||
assert_equal link_to('#'), filter_output_string
|
||||
end
|
||||
|
||||
it "repairs un-encoded spaces" do
|
||||
@body = link_to 'http://example.com/#foo bar '
|
||||
assert_equal link_to('http://example.com/#foo%20bar'), filter_output_string
|
||||
end
|
||||
|
||||
it "retains query strings" do
|
||||
@body = link_to'path?query'
|
||||
assert_equal link_to('http://example.com/dir/path?query'), filter_output_string
|
||||
|
|
Loading…
Reference in a new issue