import re
import click


def prepare_url(url):
  """Validate and prepare the URL of the test"""
  parsed = re.search(r'(http[s]*://.*)/tests/([0-9]*)[#|/]*.*', url)
  if parsed:
    click.echo('Detected test %s/tests/%s instance' % (parsed.group(2), parsed.group(1)) )
    return parsed.group(1)+'/tests/'+parsed.group(2)
  else:
    click.echo('The URL cannot be detected!')
    exit(1)