def get_resourcetypes(url):
    """ Extract the resource type from a url in form /resource/{type} or just {type}/ """
    pos = url.find('/resource/')
    if pos < 0:
        return ''
    stem = url[pos + len('/resource/'):]
    slash = stem.find('/')
    if slash >= 0:
        return stem[:slash]
    return stem
