Fix underscore within hashtag

main
Bob Mottram 2022-03-03 11:52:55 +00:00
parent 794fdbb987
commit 46dce1898a
2 changed files with 3 additions and 1 deletions

View File

@ -5328,6 +5328,8 @@ def _test_valid_hash_tag():
assert valid_hash_tag('ThisIsVälid') assert valid_hash_tag('ThisIsVälid')
assert valid_hash_tag('यहमान्यहै') assert valid_hash_tag('यहमान्यहै')
assert valid_hash_tag('한국어') assert valid_hash_tag('한국어')
assert valid_hash_tag('테스트')
assert valid_hash_tag('테_스트')
assert not valid_hash_tag('this-is-invalid') assert not valid_hash_tag('this-is-invalid')
assert not valid_hash_tag('ThisIsNotValid!') assert not valid_hash_tag('ThisIsNotValid!')
assert not valid_hash_tag('#ThisIsAlsoNotValid') assert not valid_hash_tag('#ThisIsAlsoNotValid')

View File

@ -1874,7 +1874,7 @@ def _is_valid_language(text: str) -> bool:
for lang_name, lang_range in natural_languages.items(): for lang_name, lang_range in natural_languages.items():
ok_lang = True ok_lang = True
for char in text: for char in text:
if char.isdigit(): if char.isdigit() or char == '_':
continue continue
if ord(char) not in range(lang_range[0], lang_range[1]): if ord(char) not in range(lang_range[0], lang_range[1]):
ok_lang = False ok_lang = False