<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def getLayerName(url):
 """Extract the layer name from a url. Args: url (str):
 The url to parse. Returns: str: The layer name. Examples: 'test' """

    urlInfo = None
    urlSplit = None
    try:
        urlInfo = urlparse.urlparse(url)
        urlSplit = str(urlInfo.path).split('/')
        name = urlSplit[len(urlSplit)-3]
        return name
    except:
        return url

    finally:
        urlInfo = None
        urlSplit = None

        del urlInfo
        del urlSplit

        gc.collect()