I think the direct usage of `basename()` should not have been done for an URL. It can cause a lot of holes, e.g. it will totally fail if parameters are part of the URL. Instead lets use the `urlparse()` method first to get the path, and then do a regex on the path to auto-detect the possible name. If that still fails, we should fallback to a self-generated name.