what-the-bank/sources/com/huawei/hms/framework/common/grs/GrsUtils.java

48 lines
1.6 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.huawei.hms.framework.common.grs;
import com.huawei.hms.framework.common.StringUtils;
import java.util.Locale;
/* loaded from: classes2.dex */
public class GrsUtils {
private static final int GRS_KEY_INDEX = 1;
private static final int GRS_PATH_INDEX = 2;
private static final String GRS_SCHEMA = "grs://";
private static final int GRS_SERVICE_INDEX = 0;
private static final int MAX_GRS_SPLIT = 3;
private static final String SEPARATOR = "/";
public static String[] parseParams(String str) {
if (str.endsWith(SEPARATOR)) {
str = StringUtils.substring(str, str.indexOf(GRS_SCHEMA), str.length() - 1);
}
return parseGRSSchema(str);
}
public static String[] parseGRSSchema(String str) {
String[] split = StringUtils.substring(str, str.toLowerCase(Locale.ENGLISH).indexOf(GRS_SCHEMA) + 6).split(SEPARATOR, 3);
return split.length == 1 ? new String[]{split[0], "ROOT"} : split;
}
public static String fixResult(String[] strArr, String str) {
if (strArr.length <= 2) {
return str;
}
if (str.endsWith(SEPARATOR)) {
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.append(strArr[2]);
return sb.toString();
}
StringBuilder sb2 = new StringBuilder();
sb2.append(str);
sb2.append(SEPARATOR);
sb2.append(strArr[2]);
return sb2.toString();
}
public static boolean isGRSSchema(String str) {
return str != null && str.startsWith(GRS_SCHEMA);
}
}