Minor improvement to function to retrieve curren URL.