feat: 兼容某些格式的 Trojan URI(首个 # 之后的字符串均视为节点名称)

This commit is contained in:
xream
2023-11-13 18:49:50 +08:00
parent ea88cc1794
commit 9c78b87834
2 changed files with 10 additions and 2 deletions

View File

@@ -463,8 +463,16 @@ function URI_Trojan() {
};
const parse = (line) => {
let [newLine, name] = line.split(/#(.+)/, 2);
const parser = getTrojanURIParser();
const proxy = parser.parse(line);
const proxy = parser.parse(newLine);
if (isNotBlank(name)) {
try {
proxy.name = decodeURIComponent(name);
} catch (e) {
console.log(e);
}
}
return proxy;
};
return { name, test, parse };