def join_paths(path, suffix):
  """Joins a path and a suffix into a single path.
  Resolves leading and trailing '/'. The suffix can be null.

  Examples:
    join_paths('abc/def/', '/hij') => 'abc/def/hij'
    join_paths('a', 'b/c/d') => 'a/b/c/d'
    join_paths('abc/def', None) => 'abc/def'
  """
  if not path.endswith('/'):
    path = path + '/'
  if suffix is None:
    suffix = ''
  if suffix.startswith('/'):
    suffix = suffix[1:]
  full_path = '%s%s' % (path, suffix)
  if full_path[-1] == '/':
    full_path = full_path[:-1]
  return full_path