mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-07 19:40:23 +01:00
Caching regex return in user cleanup.
(Pushing this for testing purposes).
This commit is contained in:
parent
effe0d5ec5
commit
bc2578b788
@ -22,11 +22,17 @@ public class Util
|
|||||||
}
|
}
|
||||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||||
private final static Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9]");
|
private final static Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9]");
|
||||||
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");;
|
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
|
||||||
|
private static Map<String,String> sanitizedName = new HashMap<String,String>();
|
||||||
|
|
||||||
public static String sanitizeFileName(final String name)
|
public static String sanitizeFileName(final String name)
|
||||||
{
|
{
|
||||||
return INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
|
if (sanitizedName.containsKey(name)) {
|
||||||
|
return sanitizedName.get(name);
|
||||||
|
}
|
||||||
|
final String newName = INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
|
||||||
|
sanitizedName.put(name, newName);
|
||||||
|
return newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sanitizeString(final String string)
|
public static String sanitizeString(final String string)
|
||||||
|
Loading…
Reference in New Issue
Block a user