code: def fix_post_relative_url(rel_url):
          
          m = re.match(
              r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/'
              r'(?P<post_name>[^/]+?)'
              r'(?:(?:\.html)|(?:/(?P<index>index(?:\.html?)?)?))?$',
              rel_url
          )
          if not m:
              return None
  
          year, month, day, post_name = m.groups()[:4]
          try:
              d = date(year=int(year), month=int(month), day=int(day))
              return '/'.join((d.strftime('%Y/%m/%d'), post_name,
                               'index.html' if m.group('index') else ''))
          except (TypeError, ValueError):
              # the date is invalid
              return None
docs: Fix post relative url to a standard, uniform format.
  
          Possible input:
          - 2016/7/8/my-post
          - 2016/07/08/my-post.html
          - 2016/8/09/my-post/
          - 2016/8/09/my-post/index
          - 2016/8/09/my-post/index.htm
          - 2016/8/09/my-post/index.html
  
          :param rel_url: relative url to fix
          :return: fixed relative url, or None if cannot recognize