subconverter
subconverter copied to clipboard
[BUG]有关filter_script的node的parse的问题
verify
功能描述
在subconverter的doc中,有话如下
#仅保留加密方式为chacha20的节点
filter_script=function filter(node){\n if(node.EncryptMethod.includes('chacha20'))\n return true;\n return false;\n }
# 或者使用本地文件
filter_script="path:/path/to/script.js"
而在https://github.com/tindy2013/subconverter/blob/master/base/pref.example.ini 中,却是
;Enable script support for filtering nodes
enable_filter=false
;Script used for filtering nodes. Supports inline script and script path. A "filter" function with 1 argument which is a node should be defined in the script.
;Example: Inline script: Set value to content of script. Replace all line break with "\n".
; Script path: set value to "path:/path/to/script.js".
;filter_script=function filter(node) {\n const info = JSON.parse(node.ProxyInfo);\n if(info.EncryptMethod.includes('chacha20'))\n return true;\n return false;\n}
两处的区别在于:后者有“const info = JSON.parse(node.ProxyInfo)”,亦即先从node解析到info,然后从info展开代码;而前者直接从node展开代码。
我认为它两不可能都是对的。请问,哪个是正确的?
可能的解决方案
N/A
两者都是对的,不是bug,按需使用。
两者都是对的,不是bug,按需使用。
👎 不可能的,除非作者吃饱了撑的