diff --git a/src/lucky/routable.cr b/src/lucky/routable.cr index e984869df..728a0d142 100644 --- a/src/lucky/routable.cr +++ b/src/lucky/routable.cr @@ -338,7 +338,6 @@ module Lucky::Routable \{% end %} end - private def self.path_from_parts( {% for param in path_params %} {{ param.gsub(/:/, "").id }}, @@ -351,22 +350,20 @@ module Lucky::Routable {% for part in path_parts %} {% if part.starts_with?("?:") %} if {{ part.gsub(/^\?:/, "").id }} - path << "/" - path << URI.encode_www_form({{ part.gsub(/^\?:/, "").id }}.to_param) + path << '/' + URI.encode_www_form({{ part.gsub(/^\?:/, "").id }}.to_param, path) end {% elsif part.starts_with?(':') %} - path << "/" - path << URI.encode_www_form({{ part.gsub(/:/, "").id }}.to_param) + path << '/' + URI.encode_www_form({{ part.gsub(/:/, "").id }}.to_param, path) {% else %} - path << "/" - path << URI.encode_www_form({{ part }}) + path << '/' + URI.encode_www_form({{ part }}, path) {% end %} {% end %} end - is_root_path = path == "" - path = "/" if is_root_path - path + path.presence || "/" end end