forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#31116 from artus9033/proposal/30985
fix: unify word breaking in ContextMenuItem for Android mweb and Android native
- Loading branch information
Showing
3 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Trims the `mailto:` part from mail link. | ||
* @param mailLink - The `mailto:` link to be trimmed | ||
* @returns The email address | ||
*/ | ||
function trimMailTo(mailLink: string) { | ||
return mailLink.replace('mailto:', ''); | ||
} | ||
|
||
/** | ||
* Prepends a zero-width space (U+200B) character before all `.` and `@` characters | ||
* in the email address to provide explicit line break opportunities for consistent | ||
* breaking across platforms. | ||
* | ||
* Note: as explained [here](https://github.com/Expensify/App/issues/30985#issuecomment-1815379835), | ||
* this only provides opportunities for line breaking (rather than forcing line breaks) that shall | ||
* be used by the platform implementation when there are no other customary rules applicable | ||
* and the text would otherwise overflow. | ||
* @param email - The email address to be sanitized | ||
* @returns The email with inserted line break opportunities | ||
*/ | ||
function prefixMailSeparatorsWithBreakOpportunities(email: string) { | ||
return email.replace( | ||
/([.@])/g, | ||
// below: zero-width space (U+200B) character | ||
'$1', | ||
); | ||
} | ||
|
||
export default {trimMailTo, prefixMailSeparatorsWithBreakOpportunities}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters