Refactor checking for external links to be clearer