def redir_old()

in server/scripts/redirector.py [0:0]


def redir_old(kwargs, channel):
  """Crufty old code that hasn't been touched in a long time. Still here for
  legacy reasons to not break old links. :-/ Let sleeping dogs lie?"""
  old_path = kwargs['path'][1:]
  if (old_path == ''):
    return '/apidocs/channels/stable/dartdoc-viewer/home'
  split = old_path.split('/')
  firstPart = split[0]
  if (len(split) > 1):
    secondPart = '.' + split[1]
  else:
    secondPart = ''
  packages = ['args', 'crypto', 'custom_element', 'fixnum', 'http_server',
    'intl', 'json', 'logging', 'matcher', 'mime', 'mock', 'observe', 'path',
    'polymer', 'polymer_expressions', 'sequence_zip', 'serialization',
    'source_maps', 'template_binding', 'unittest', 'unmodifiable_collection',
    'utf']
  withNoDot = firstPart.split('.')[0]
  if withNoDot in packages:
    prefix = firstPart + '/' + firstPart
  else:
    prefix = firstPart.replace('_', ':', 1).replace('.html', '')
    # For old URLs like core/String.html. We know it's not a package, so
    # it ought to start with a dart: library
    if (not prefix.startswith("dart:")):
      prefix = "dart:" + prefix
  new_path = prefix + secondPart.replace('.html','')
  # Should be #! if we use that scheme
  return '/' + channel