Skip to content

Commit

Permalink
feat: support clash no-resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed Jan 3, 2020
1 parent 0d107f6 commit cd349bc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
1 change: 0 additions & 1 deletion lib/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default function getEngine(templateDir: string, publicUrl: string): nunju
return item;
}
return `- ${item}`
.replace(/,no-resolve/, '')
.replace(/\/\/.*$/, '')
.trim();
})
Expand Down
32 changes: 16 additions & 16 deletions test/snapshots/template.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,15 @@ Generated by [AVA](https://ava.li).
- DOMAIN-SUFFIX,nflximg.net␊
- DOMAIN-SUFFIX,nflxso.net␊
- DOMAIN-SUFFIX,nflxvideo.net␊
- IP-CIDR,23.246.0.0/18␊
- IP-CIDR,37.77.184.0/21␊
- IP-CIDR,45.57.0.0/17␊
- IP-CIDR,64.120.128.0/17␊
- IP-CIDR,66.197.128.0/17␊
- IP-CIDR,108.175.32.0/20␊
- IP-CIDR,192.173.64.0/18␊
- IP-CIDR,198.38.96.0/19␊
- IP-CIDR,198.45.48.0/20␊
- IP-CIDR,23.246.0.0/18,no-resolve
- IP-CIDR,37.77.184.0/21,no-resolve
- IP-CIDR,45.57.0.0/17,no-resolve
- IP-CIDR,64.120.128.0/17,no-resolve
- IP-CIDR,66.197.128.0/17,no-resolve
- IP-CIDR,108.175.32.0/20,no-resolve
- IP-CIDR,192.173.64.0/18,no-resolve
- IP-CIDR,198.38.96.0/19,no-resolve
- IP-CIDR,198.45.48.0/20,no-resolve
# > niconico␊
- DOMAIN-SUFFIX,dmc.nico␊
- DOMAIN-SUFFIX,nicovideo.jp␊
Expand Down Expand Up @@ -589,14 +589,14 @@ Generated by [AVA](https://ava.li).
> Snapshot 1
`# RULE 1␊
^https?://m?api\\.weibo\\.c(n|om)/2/(statuses/(unread|extend|positives/get|(friends|video)(/|_)timeline)|stories/(video_stream|home_list)|(groups|fangle)/timeline|profile/statuses|comments/build_comments|photo/recommend_list|service/picfeed|searchall|cardlist|page|\\!/photos/pic_recommend_status) url script-response-body http://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fyichahucha%2Fsurge%2Fmaster%2Fwb_ad.js␊
^https?://(sdk|wb)app\\.uve\\.weibo\\.com(/interface/sdk/sdkad.php|/wbapplua/wbpullad.lua) url script-response-body http://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fyichahucha%2Fsurge%2Fmaster%2Fwb_launch.js␊
^https?://m?api\\.weibo\\.c(n|om)/2/(statuses/(unread|extend|positives/get|(friends|video)(/|_)timeline)|stories/(video_stream|home_list)|(groups|fangle)/timeline|profile/statuses|comments/build_comments|photo/recommend_list|service/picfeed|searchall|cardlist|page|\\!/photos/pic_recommend_status) url script-response-body https://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fyichahucha%2Fsurge%2Fmaster%2Fwb_ad.js␊
^https?://(sdk|wb)app\\.uve\\.weibo\\.com(/interface/sdk/sdkad.php|/wbapplua/wbpullad.lua) url script-response-body https://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fyichahucha%2Fsurge%2Fmaster%2Fwb_launch.js␊
# RULE 2␊
https://api.zhihu.com/moments\\?(action|feed_type) url script-response-body http://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fonewayticket255%2FSurge-Script%2Fmaster%2Fsurge%2520zhihu%2520feed.js␊
https://api.zhihu.com/topstory/recommend url script-response-body http://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fonewayticket255%2FSurge-Script%2Fmaster%2Fsurge%2520zhihu%2520recommend.js␊
https://api.zhihu.com/.*/questions url script-response-body http://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fonewayticket255%2FSurge-Script%2Fmaster%2Fsurge%2520zhihu%2520answer.js␊
https://api.zhihu.com/market/header url script-response-body http://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fonewayticket255%2FSurge-Script%2Fmaster%2Fsurge%2520zhihu%2520market.js␊
https://api.zhihu.com/people/ url script-response-body http://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fonewayticket255%2FSurge-Script%2Fmaster%2Fsurge%2520zhihu%2520people.js␊
https://api.zhihu.com/moments\\?(action|feed_type) url script-response-body https://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fonewayticket255%2FSurge-Script%2Fmaster%2Fsurge%2520zhihu%2520feed.js␊
https://api.zhihu.com/topstory/recommend url script-response-body https://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fonewayticket255%2FSurge-Script%2Fmaster%2Fsurge%2520zhihu%2520recommend.js␊
https://api.zhihu.com/.*/questions url script-response-body https://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fonewayticket255%2FSurge-Script%2Fmaster%2Fsurge%2520zhihu%2520answer.js␊
https://api.zhihu.com/market/header url script-response-body https://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fonewayticket255%2FSurge-Script%2Fmaster%2Fsurge%2520zhihu%2520market.js␊
https://api.zhihu.com/people/ url script-response-body https://example.com/qx-script?url=https%3A%2F%2Fraw.githubusercontent.com%2Fonewayticket255%2FSurge-Script%2Fmaster%2Fsurge%2520zhihu%2520people.js␊
# RULE 3`

## stringify
Expand Down
Binary file modified test/snapshots/template.test.ts.snap
Binary file not shown.
4 changes: 2 additions & 2 deletions test/template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('clash #1', t => {
str,
});

t.is(result, `- IP-CIDR,67.198.55.0/24,Proxy`);
t.is(result, `- IP-CIDR,67.198.55.0/24,Proxy,no-resolve`);
});

test('clash #2', t => {
Expand All @@ -23,7 +23,7 @@ test('clash #2', t => {
str,
});

t.is(result, `- IP-CIDR,67.198.55.0/24,Proxy`);
t.is(result, `- IP-CIDR,67.198.55.0/24,Proxy,no-resolve`);
});

test('clash #3', t => {
Expand Down

0 comments on commit cd349bc

Please sign in to comment.