Skip to content

Commit 429a2e9

Browse files
committed
feat(overwrite): set provider format by extension
Add an overwrite that infers and sets rule-provider 'format' from URL or path extensions. Implements .mrs -> mrs and .yaml/.yml -> yaml, ignores query/fragment and case, prefers URL first for remote providers and path first for file-type providers, and leaves other formats unchanged. Implemented via a ruby_edit script in overwrite/Rule_Provider_Format_Fix.conf.
1 parent 4b1ead7 commit 429a2e9

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[Overwrite]
2+
# 修正规则提供者格式:
3+
# - 远程 rule-provider 优先根据 url 后缀判断,再回退检查 path
4+
# - type: file 优先根据 path 后缀判断,再回退检查 url
5+
# - .mrs 设为 format: mrs
6+
# - .yaml/.yml 设为 format: yaml
7+
# - URL 查询参数和片段不影响判断,扩展名不区分大小写
8+
# - 其他格式保持不变
9+
ruby_edit "$CONFIG_FILE" "; providers=Value['rule-providers']; if providers.is_a?(Hash); providers.each_value do |provider|; next unless provider.is_a?(Hash); candidates=provider['type'].to_s=='file' ? [provider['path'],provider['url']] : [provider['url'],provider['path']]; source=candidates.compact.map{|item| item.to_s.split(/[?#]/,2).first.downcase}.find{|item| item.end_with?('.mrs') || item.end_with?('.yaml') || item.end_with?('.yml')}.to_s; if source.end_with?('.mrs'); provider['format']='mrs'; elsif source.end_with?('.yaml') || source.end_with?('.yml'); provider['format']='yaml'; end; end; end; _openclash_rule_provider_format_fix" "nil"

0 commit comments

Comments
 (0)