Sanitize app names and shorten screenshot names #349
Merged
navodzoysa
merged 2 commits from ashvini/device-mgt-core:Improvement-#9241
into master
9 months ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'ashvini/device-mgt-core:Improvement-#9241'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Fixes:
https://roadmap.entgra.net/issues/9241
https://roadmap.entgra.net/issues/10628
* @return Sanitized and shortened file name
*/
public static String sanitizeName(String originalName, String type) {
String sanitizedName = originalName.replaceAll("[^a-zA-Z0-9.\\s-]", "");
Can move the regex pattern to a constant as it could be reused in the future.
*/
public static String sanitizeName(String originalName, String type) {
String sanitizedName = originalName.replaceAll("[^a-zA-Z0-9.\\s-]", "");
if (type.equals(Constants.ApplicationProperties.NAME) && sanitizedName.length() > 350) {
Use the constant on the left side of the comparison to avoid null pointer exception.
Also avoid using magic numbers (350) instead use a constant like MAX_CHARACTER_LENGTH
}
return type + fileExtension;
} else
return sanitizedName;
Enclose else condition with curly braces for better readability.
464214fe1b
into master 9 months agoReviewers
464214fe1b
.