Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit

Permalink
Refactor logic to handle multiple spaces, leading and trailing spaces…
Browse files Browse the repository at this point in the history
… in customer name
AnirudhBhat committed Nov 26, 2024

Verified

This commit was signed with the committer’s verified signature.
folkertdev Folkert de Vries
1 parent d76f381 commit 3b5294e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -117,7 +117,10 @@ class WCCustomerMapper @Inject constructor() {
}
}

private fun String?.firstNameFromName() = this?.substringBefore(" ") ?: ""
private fun String?.firstNameFromName(): String =
this?.trim()?.replace("\\s+".toRegex(), " ")?.substringBefore(" ") ?: ""

private fun String?.lastNameFromName(): String =
this?.trim()?.replace("\\s+".toRegex(), " ")?.substringAfter(" ", "") ?: ""

private fun String?.lastNameFromName() = this?.substringAfter(" ", "") ?: ""
}

0 comments on commit 3b5294e

Please sign in to comment.