I think the logic can be simplified if you assume that the caller always sends a list (and if the caller needs a single url, then the caller with construct a list with single element).