More robust toc url handling