MCPcopy Create free account
hub / github.com/FabricMC/Matcher / escapeId

Method escapeId

src/main/java/matcher/srcprocess/HtmlUtil.java:17–47  ·  view source on GitHub ↗
(String str)

Source from the content-addressed store, hash-verified

15 }
16
17 private static String escapeId(String str) {
18 StringBuilder ret = null;
19 int retEnd = 0;
20
21 for (int i = 0, max = str.length(); i < max; i++) {
22 char c = str.charAt(i);
23
24 if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9') && c != '-' && c != '_' && c != '.') { // use : as an escape identifier
25 if (ret == null) ret = new StringBuilder(max * 2);
26
27 ret.append(str, retEnd, i);
28
29 ret.append(':');
30
31 for (int j = 0; j < 4; j++) {
32 int v = (c >>> ((3 - j) * 4)) & 0xf;
33 ret.append("0123456789abcdef".charAt(v));
34 }
35
36 retEnd = i + 1;
37 }
38 }
39
40 if (ret == null) {
41 return str;
42 } else {
43 ret.append(str, retEnd, str.length());
44
45 return ret.toString();
46 }
47 }
48
49 public static String escape(String str, String... allowedTags) {
50 Pattern tagPattern = compileTagPattern(allowedTags);

Callers 1

getIdMethod · 0.95

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected