feat: 支持使用代理/节点/策略获取订阅

This commit is contained in:
xream
2024-03-13 01:55:16 +08:00
parent ca65e4209e
commit 80d46597b4
8 changed files with 88 additions and 17 deletions

View File

@@ -35,6 +35,17 @@ function getIfPresent(obj, defaultValue) {
return isPresent(obj) ? obj : defaultValue;
}
function getPolicyDescriptor(str) {
if (!str) return {};
return /^.+?\s*?=\s*?.+?\s*?,.+?/.test(str)
? {
'policy-descriptor': str,
}
: {
policy: str,
};
}
const utf8ArrayToStr =
typeof TextDecoder !== 'undefined'
? (v) => new TextDecoder().decode(new Uint8Array(v))
@@ -91,4 +102,5 @@ export {
isPresent,
getIfPresent,
utf8ArrayToStr,
getPolicyDescriptor,
};