mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Make reject filter download abortable
This commit is contained in:
@@ -133,11 +133,19 @@ async function processFilterRules(filterRulesUrl, fallbackUrls, includeThirdPart
|
||||
|
||||
let filterRules;
|
||||
try {
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
|
||||
/** @type string[] */
|
||||
filterRules = (
|
||||
await Promise.any(
|
||||
[filterRulesUrl, ...(fallbackUrls || [])].map(
|
||||
async url => (await fetchWithRetry(url)).text()
|
||||
url => fetchWithRetry(url, { signal })
|
||||
.then(r => r.text())
|
||||
.then(text => {
|
||||
controller.abort();
|
||||
return text;
|
||||
})
|
||||
)
|
||||
)
|
||||
).split('\n').map(line => line.trim());
|
||||
|
||||
Reference in New Issue
Block a user