The answers still concern the line itself. What you are actually doing says that it has the parameters "" . If you do this nil , if params.to_param == "" you will not have this problem.
def url_without_locale_params(url) uri = URI url params = Rack::Utils.parse_query uri.query params.delete 'locale' uri.query = params.to_param.blank? ? nil : params.to_param uri.to_s end
something like this should do the trick. The reason for this is that even with an empty string, the URI assumes something is being added, so does it put the initial one ? in.
Mike campbell
source share