Skip to content

Commit ad13ce6

Browse files
authored
fix: generating shortIds for vless reality (#2745)
1 parent c35179d commit ad13ce6

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

web/assets/js/util/index.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,20 @@ class PromiseUtil {
8181
}
8282

8383
class RandomUtil {
84-
static getSeq({ hasNumbers = true, hasLowercase = true, hasUppercase = true } = {}) {
84+
static getSeq({ type = "default", hasNumbers = true, hasLowercase = true, hasUppercase = true } = {}) {
8585
let seq = '';
86-
if (hasNumbers) seq += "0123456789";
87-
if (hasLowercase) seq += "abcdefghijklmnopqrstuvwxyz";
88-
if (hasUppercase) seq += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
86+
87+
switch (type) {
88+
case "hex":
89+
seq += "0123456789abcdef";
90+
break;
91+
default:
92+
if (hasNumbers) seq += "0123456789";
93+
if (hasLowercase) seq += "abcdefghijklmnopqrstuvwxyz";
94+
if (hasUppercase) seq += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
95+
break;
96+
}
97+
8998
return seq;
9099
}
91100

@@ -107,7 +116,7 @@ class RandomUtil {
107116
static randomShortIds() {
108117
const lengths = [2, 4, 6, 8, 10, 12, 14, 16].sort(() => Math.random() - 0.5);
109118

110-
return lengths.map(len => this.randomSeq(len)).join(',');
119+
return lengths.map(len => this.randomSeq(len, { type: "hex" })).join(',');
111120
}
112121

113122
static randomLowerAndNum(len) {

0 commit comments

Comments
 (0)