1 Star 0 Fork 68

玛奇朵/Unlock-netease-cloud-music

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
endpoint.worker.js 735 Bytes
一键复制 编辑 原始数据 按行查看 历史
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
const pattern = /^\/package\/([0-9a-zA-Z_\-=]+)\/(\w+\.\w+)$/
const handleRequest = async request => {
const notFound = new Response(null, { status: 404 })
const path = new URL(request.url).pathname
const [matched, base64Url, fileName] = pattern.exec(path || '') || []
if (!matched) return notFound
let url = base64Url.replace(/-/g, '+').replace(/_/g, '/')
try { url = new URL(atob(url)) } catch(_) { url = null }
if (!url) return notFound
const headers = new Headers(request.headers)
headers.set('host', url.host)
headers.delete('cookie')
const { method, body } = request
return fetch(url, { method, headers, body })
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ericsbox/Unlock-netease-cloud-music.git
git@gitee.com:ericsbox/Unlock-netease-cloud-music.git
ericsbox
Unlock-netease-cloud-music
Unlock-netease-cloud-music
master

搜索帮助