(slug)
| 34 | } |
| 35 | |
| 36 | async function probe(slug) { |
| 37 | const ctrl = new AbortController(); |
| 38 | const t = setTimeout(() => ctrl.abort(), TIMEOUT_MS); |
| 39 | try { |
| 40 | const res = await fetch(`${HOST}/${slug}`, { signal: ctrl.signal, redirect: "follow" }); |
| 41 | if (!res.ok) return false; |
| 42 | const html = await res.text(); |
| 43 | const m = html.match(/<title>([\s\S]*?)<\/title>/i); |
| 44 | const title = m ? m[1].trim() : ""; |
| 45 | // 标题恰好等于首页标题(或为空)说明该 slug 不存在,paicoding 用首页兜底 |
| 46 | return title !== "" && title !== HOME_TITLE; |
| 47 | } catch { |
| 48 | return null; // 网络异常:返回 null,调用方据此保留旧清单中的该项 |
| 49 | } finally { |
| 50 | clearTimeout(t); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | async function pool(items, worker, size) { |
| 55 | const results = new Array(items.length); |
nothing calls this directly
no outgoing calls
no test coverage detected