Skip to content

Commit

Permalink
The #getTwilioLocale() switch can't be null (until JDK 21) so add a c…
Browse files Browse the repository at this point in the history
…heck.
  • Loading branch information
JymDyerIBI committed Nov 9, 2023
1 parent e280eea commit 0523ced
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ public static String sendSMS(String toPhone, String body) {
* See https://www.twilio.com/docs/verify/supported-languages#verify-default-template
*/
public static String getTwilioLocale(String locale) {
if (locale == null) {
return "en";
}
// The Twilio's supported locales are just the first two letters of the user's locale,
// unless it is zh-HK, pt-BR, or en-GB.
switch (locale) {
Expand All @@ -156,7 +159,7 @@ public static String getTwilioLocale(String locale) {
case "zh-HK":
return locale;
default:
return locale == null || locale.length() < 2 ? "en" : locale.substring(0, 2);
return locale.length() < 2 ? "en" : locale.substring(0, 2);
}
}

Expand Down

0 comments on commit 0523ced

Please sign in to comment.