This handles the edge case when the user types something like ls localhost:19998.
I'll check again for files, but I recall we remove trailing /