Kaynağa Gözat

Fix internal paths with ':' characters not getting clean up properly

Fix #402.
Thibaut Courouble 9 yıl önce
ebeveyn
işleme
2813cf9be3

+ 4 - 0
lib/docs/core/filter.rb

@@ -85,5 +85,9 @@ module Docs
 
       URI.decode(result)
     end
+
+    def clean_path(path)
+      path.gsub %r{[!;:]+}, '-'
+    end
   end
 end

+ 1 - 0
lib/docs/filters/core/internal_urls.rb

@@ -81,6 +81,7 @@ module Docs
     def internal_path_to(url)
       url = index_url if url == root_url
       path = effective_url.relative_path_to(url)
+      path = clean_path(path) if context[:decode_and_clean_paths]
       URL.new(path: path, query: url.query, fragment: url.fragment).to_s
     end
 

+ 1 - 1
lib/docs/filters/core/normalize_paths.rb

@@ -37,7 +37,7 @@ module Docs
 
       if context[:decode_and_clean_paths]
         path = URI.unescape(path)
-        path.gsub! %r{[!;:]+}, '-'
+        path = clean_path(path)
       end
 
       if path == '.'