Skip to content

Commit

Permalink
Set default ascii strategy to remove non matching characters so that …
Browse files Browse the repository at this point in the history
…existing functionality remains the same.
  • Loading branch information
yamatt committed Nov 7, 2024
1 parent 5e10813 commit 10c837a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion homoglyphs_fork/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def get_all(cls):

class Homoglyphs:
def __init__(self, categories=None, languages=None, alphabet=None,
strategy=STRATEGY_IGNORE, ascii_strategy=STRATEGY_IGNORE,
strategy=STRATEGY_IGNORE, ascii_strategy=STRATEGY_REMOVE,
ascii_range=ASCII_RANGE):
"""
:param ascii_strategy: action to take on unmatched char when converting to ascii
Expand Down
5 changes: 4 additions & 1 deletion tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ def test_ascii_strategy(self):
).to_ascii(u'ч')
self.assertEqual(ss, [])

# this test is based on https://github.com/yamatt/homoglyphs/issues/4
# these tests are based on https://github.com/yamatt/homoglyphs/issues/4
ss = Homoglyphs().to_ascii('ß')
self.assertEqual(ss, [])

ss = Homoglyphs(ascii_strategy=STRATEGY_IGNORE).to_ascii('ß')
self.assertEqual(ss, ['ß'])

Expand Down

0 comments on commit 10c837a

Please sign in to comment.