Consolidate link handling code
Merge with Master
Urls fixes
Merge pull request #4718 from TomMalbran/tom/issue-3556

Fix issue #3556: Consolidate link handling code