Add more resilient parsing of the possible origin urls and add a test