Skip to content

get_domain is ill defined. #3356

Open
Open
@karlcow

Description

@karlcow

so get_domain helps extracting a domain name from a title.

def get_domain(title):
"""Get the 'domain name' from the title.
In practice, this just grabs the first string before
the first whitespace, because that's where we put the
domain when we passed it to GitHub upon creation.
"""
domain = re.search(r'^([^ ]+)', title)
if domain:
return domain.group(1)
else:
return ''

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

def test_get_domain(self):
"""Test domain name extraction from title.
(This really means give us the first pile of strings before
the first whitespace).
"""
title = 'staging.webcompat.com - site is not usable'
assert get_domain(title) == 'staging.webcompat.com'
title = '😎 😓'
assert get_domain(title) == '😎'

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' ➡️ ''

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions