Skip to content

Commit 2813cf9

Browse files
committed
Fix internal paths with ':' characters not getting clean up properly
Fix freeCodeCamp#402.
1 parent 84566ea commit 2813cf9

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

lib/docs/core/filter.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,9 @@ def decode_cloudflare_email(str)
8585

8686
URI.decode(result)
8787
end
88+
89+
def clean_path(path)
90+
path.gsub %r{[!;:]+}, '-'
91+
end
8892
end
8993
end

lib/docs/filters/core/internal_urls.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def normalize_url(url, subpath)
8181
def internal_path_to(url)
8282
url = index_url if url == root_url
8383
path = effective_url.relative_path_to(url)
84+
path = clean_path(path) if context[:decode_and_clean_paths]
8485
URL.new(path: path, query: url.query, fragment: url.fragment).to_s
8586
end
8687

lib/docs/filters/core/normalize_paths.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def normalize_path(path)
3737

3838
if context[:decode_and_clean_paths]
3939
path = URI.unescape(path)
40-
path.gsub! %r{[!;:]+}, '-'
40+
path = clean_path(path)
4141
end
4242

4343
if path == '.'

0 commit comments

Comments
 (0)