webcompat.com icon indicating copy to clipboard operation
webcompat.com copied to clipboard

get_domain is ill defined.

Open karlcow opened this issue 5 years ago • 0 comments

so get_domain helps extracting a domain name from a title.

https://github.com/webcompat/webcompat.com/blob/8656f17526d3b64c367ea4f2bbb742a2b388c937/webcompat/templates/init.py#L79-L90

The function returns the first group of continuous text before a space, but the case return '' is not covered in the testing

https://github.com/webcompat/webcompat.com/blob/8656f17526d3b64c367ea4f2bbb742a2b388c937/tests/unit/test_template.py#L43-L52

and indeed the only case where this would happen is when title = '' which is probably not the initial intent of get_domain.

So

  1. There's a missing test
  2. There might be a modification to do to the regex to really match what we want.

which is probably along

  • 'staging.webcompat.com - site is not usable' ➡️ 'staging.webcompat.com'
  • 'site is not usable' ➡️ ''

karlcow avatar Jun 18 '20 11:06 karlcow