Merge pull request #2164 from cryode/bug/auto_link

Fix and optimize auto_link() URL helper function.