fix: _trim_to_letter_end matches full name when no profile set
All checks were successful
CI / test (pull_request) Successful in 42s
All checks were successful
CI / test (pull_request) Successful in 42s
When _profile is None the fallback pattern \w+ only matched the first word of a two-word sign-off (e.g. 'Alex' from 'Alex Rivera'), silently dropping the last name. Switch fallback to \w+(?:\s+\w+)? so a full first+last sign-off is preserved in no-config environments (CI, first run).
This commit is contained in:
parent
4a996c2628
commit
971336841f
1 changed files with 1 additions and 1 deletions
|
|
@ -221,7 +221,7 @@ def _trim_to_letter_end(text: str) -> str:
|
||||||
candidate_first = (_profile.name.split()[0] if _profile else "").strip()
|
candidate_first = (_profile.name.split()[0] if _profile else "").strip()
|
||||||
pattern = (
|
pattern = (
|
||||||
r'(?:Warm regards|Sincerely|Best regards|Kind regards|Thank you)[,.]?\s*\n+\s*'
|
r'(?:Warm regards|Sincerely|Best regards|Kind regards|Thank you)[,.]?\s*\n+\s*'
|
||||||
+ (re.escape(candidate_first) if candidate_first else r'\w+')
|
+ (re.escape(candidate_first) if candidate_first else r'\w+(?:\s+\w+)?')
|
||||||
+ r'\b'
|
+ r'\b'
|
||||||
)
|
)
|
||||||
m = re.search(pattern, text, re.IGNORECASE)
|
m = re.search(pattern, text, re.IGNORECASE)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue