code: def clean_path_middleware(environ, start_response=None):
      '''Clean url from double slashes and redirect if needed.'''
      path = environ['PATH_INFO']
      if path and '//' in path:
          url = re.sub("/+", '/', path)
          if not url.startswith('/'):
              url = '/%s' % url
          qs = environ['QUERY_STRING']
          if qs:
              url = '%s?%s' % (url, qs)
          raise HttpRedirect(urlf clean_path_middleware(environ, start_response=None):
      '''Clean url from double slashes and redirect if needed.'''
      path = environ['PATH_INFO']
      if path and '//' in path:
          url = re.sub("/+", '/', path)
          if not url.startswith('/'):
              url = '/%s' % url
          qs = environ['QUERY_STRING']
          if qs:
              url = '%s?%s' % (url, qs)
          raise HttpRedirect(url)
docs: Clean url from double slashes and redirect if needed.