Skip to content

Commit aa5013c

Browse files
committed
解析
1 parent 0ece001 commit aa5013c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

_worker.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,11 @@ export default {
503503
const dest = new URL(request.url).searchParams.get('dest');
504504
// 获取地址dest的内容
505505
const text = await (await fetch(dest)).text();
506-
// 解析所有div标签的属性data-snippet-clipboard-copy-content,结果为纯文本,每行一个,处理&
507-
const divText = text.replace(/<div[^>]*?data-snippet-clipboard-copy-content="([^"]+?)"/g, '\n$1\n').replace(/&amp;/g, '&');
506+
// 解析并提取所有div标签的属性data-snippet-clipboard-copy-content,结果为纯文本,每行一个,处理&amp;
507+
const divText = [...text.matchAll(/<div[^>]*?data-snippet-clipboard-copy-content="([^"]*)"/g)]
508+
.map(m => m[1])
509+
.join('\n')
510+
.replace(/&amp;/g, '&');
508511
return new Response(divText, { status: 200, headers: { 'Content-Type': 'text/plain; charset=UTF-8' } });
509512
}
510513
} else if (!envUUID) return fetch(Pages静态页面 + '/noKV').then(r => { const headers = new Headers(r.headers); headers.set('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate'); headers.set('Pragma', 'no-cache'); headers.set('Expires', '0'); return new Response(r.body, { status: 404, statusText: r.statusText, headers }) });

0 commit comments

Comments
 (0)