All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arextest.schedule.comparer.EncodingUtils Maven / Gradle / Ivy

There is a newer version: 2.0.4
Show newest version
package com.arextest.schedule.comparer;

import java.util.Base64;

/**
 * Created by qzmo on 2023-11-27
 * 

* Extracted from DefaultReplayResultComparer */ public class EncodingUtils { public static String tryBase64Decode(String encoded) { try { if (encoded == null) { return null; } if (isJson(encoded)) { return encoded; } String decoded = new String(Base64.getDecoder().decode(trimBase64Str(encoded))); if (isJson(decoded)) { return decoded; } return encoded; } catch (Exception e) { return encoded; } } private static boolean isJson(String value) { if (value.startsWith("{") && value.endsWith("}")) { return true; } else { return value.startsWith("[") && value.endsWith("]"); } } private static String trimBase64Str(String in) { return in.replace("\"", ""); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy