fix a bug where URLs sometimes got ?undefined on the end