We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dfc5e80 commit 8d1b9fdCopy full SHA for 8d1b9fd
actionpack/lib/action_dispatch/journey/router/utils.rb
@@ -17,7 +17,14 @@ class Utils # :nodoc:
17
# normalize_path("") # => "/"
18
# normalize_path("/%ab") # => "/%AB"
19
def self.normalize_path(path)
20
- path ||= ""
+ return "/".dup unless path
21
+
22
+ # Fast path for the overwhelming majority of paths that don't need to be normalized
23
+ if path == "/" || (path.start_with?("/") && !path.end_with?("/") && !path.match?(%r{%|//}))
24
+ return path.dup
25
+ end
26
27
+ # Slow path
28
encoding = path.encoding
29
path = +"/#{path}"
30
path.squeeze!("/")
0 commit comments