Skip to content

Commit 9af844e

Browse files
committed
added common function for base client name
1 parent fde1d67 commit 9af844e

File tree

1 file changed

+13
-3
lines changed
  • src/main/java/net/b07z/sepia/server/core/assistant

1 file changed

+13
-3
lines changed

src/main/java/net/b07z/sepia/server/core/assistant/CLIENTS.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,19 @@ public class CLIENTS {
2424
final public static String WAKEWORD_TOOL = "wakeword_tool";
2525

2626
/**
27-
* Check for environment by comparing the input environment (this_env) to an array of
28-
* test environments (test_envies). E.g. you want to check for a web app running on iOS use:
29-
* compare(this_env, ENVIRONMENTS.WEB_APP, ENVIRONMENTS.iOS).
27+
* Return basic for of the client, e.g. convert "web_app_v1.0.1" to "web_app".
28+
* @param clientInfo - info given by any client
29+
*/
30+
public static String getBaseClient(String clientInfo){
31+
return clientInfo.replaceFirst("_v\\d.*?(_|$)", "_").trim().replaceFirst("_$", "").replaceAll("[\\W]", "").trim();
32+
}
33+
34+
//TODO: I think we need to update/simplify this ... and we should write some tests as well! ;-)
35+
36+
/**
37+
* Check for client by comparing the input client (this_env) to an array of
38+
* test clients (test_envies). E.g. you want to check for a web app running on iOS use:
39+
* compare(this_env, CLIENTS.IOS_APP, CLIENTS.IOS_BROWSER).
3040
*
3141
* @param this_env - input environment
3242
* @param test_envies - array of tests

0 commit comments

Comments
 (0)