mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Merge branch 'unicode_deck_name' into 'master'
support unicode deck name See merge request core-developers/forge!2472
This commit is contained in:
@@ -19,6 +19,8 @@ package forge.deck;
|
||||
|
||||
import forge.item.InventoryItem;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public abstract class DeckBase implements Serializable, Comparable<DeckBase>, InventoryItem {
|
||||
private static final long serialVersionUID = -7538150536939660052L;
|
||||
@@ -143,7 +145,13 @@ public abstract class DeckBase implements Serializable, Comparable<DeckBase>, In
|
||||
* @return the best file name
|
||||
*/
|
||||
public final String getBestFileName() {
|
||||
return name.replaceAll("[^-_$#@.,{[()]} a-zA-Z0-9]", "");
|
||||
//string operator hard to guarantee filename legal,only replace some not allowed as file names characters
|
||||
final String result = name.replaceAll("[\\/:*?\"<>|]","");
|
||||
if (result.isEmpty()) {
|
||||
final String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm"));
|
||||
return createTime;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public abstract boolean isEmpty();
|
||||
|
||||
Reference in New Issue
Block a user