package envoy.client.util; /** * Provides methods to handle outgoing issues. *
* Project: client
* File: IssueUtil.java
* Created: 20.08.2020
*
* @author Leon Hofmeister
* @since Envoy Client v0.2-beta
*/
public class IssueUtil {
/**
*
* @since Envoy Client v0.2-beta
*/
private IssueUtil() {}
/**
* Performs actions to ensure the description of an issue will be displayed as
* intended by the user.
*
* @param rawDescription the description to sanitize
* @param username the user who submitted the issue. Should be
* {@code null} if he does not want to be named.
* @return the sanitized description
* @since Envoy Client v0.2-beta
*/
public static String sanitizeIssueDescription(String rawDescription, String username) {
// Appending the submitter name, if this option was enabled
rawDescription += username != null
? (rawDescription.endsWith("\n") || rawDescription.endsWith("
") ? "" : "
") + String.format("Submitted by user %s.", username)
: "";
// Markdown does not support "normal" line breaks. It uses "
"
rawDescription = rawDescription.replaceAll(System.getProperty("line.separator", "\r?\n"), "
");
return rawDescription;
}
}