-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: merge pull request #343 from imyanice/main
ed: small tweaks to make everything as smooth as possible
- Loading branch information
Showing
3 changed files
with
13 additions
and
10 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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
function parse_initials (content: string): string { | ||
const initials = content.split(" ").map((word) => word[0].toUpperCase()).join(""); | ||
let formattedInitials = initials.slice(1); | ||
if (formattedInitials.length === 0) { | ||
if (content.split(" ").length === 1) formattedInitials = content; | ||
else formattedInitials = "??"; | ||
} | ||
function parse_initials (content: string) { | ||
content = content.trimStart().trimEnd(); | ||
if (content === "") return "??"; | ||
let initials = content.split(" ").map((word) => word[0].toUpperCase()).join(""); | ||
|
||
return formattedInitials; | ||
if (initials.length === 0) { | ||
if (content.split(" ").length === 1) initials = content; | ||
else initials = "??"; | ||
} else if (initials.length === 3) initials = initials.slice(1); // We assume it's in the format M. J. Dupont ou MMe. C. Dupont | ||
return initials; | ||
} | ||
|
||
export default parse_initials; |
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