import re


def _ShortenRietveld(o):
  """Shorten a rietveld URI.

  Args:
    o: The named tuple from a urllib.parse.urlsplit call.

  Returns:
    A new named tuple that can be passed to urllib.parse.urlunsplit.
  """
  m = re.match(r'^/([0-9]+)', o.path)
  if m:
    o = o._replace(netloc='crrev.com',
                   path='/%s' % (m.group(1),))

  return o._replace(scheme='https')