(string: str, fn: Callable[[str], str])
| 37 | |
| 38 | |
| 39 | def map_domain(string: str, fn: Callable[[str], str]) -> str: |
| 40 | parts = string.split("@") |
| 41 | result = "" |
| 42 | if len(parts) > 1: |
| 43 | # In email addresses, only the domain name should be punycoded. Leave |
| 44 | # the local part (i.e. everything up to `@`) intact. |
| 45 | result = parts[0] + "@" |
| 46 | string = parts[1] |
| 47 | labels = REGEX_SEPARATORS.split(string) |
| 48 | encoded = ".".join(fn(label) for label in labels) |
| 49 | return result + encoded |
| 50 | |
| 51 | |
| 52 | def to_unicode(obj: str) -> str: |
no outgoing calls
no test coverage detected
searching dependent graphs…