edited regex on router stuff

This commit is contained in:
uh wot 2021-08-16 18:03:20 +02:00
parent 396c662ef3
commit 756221a4b1
Signed by: uhwot
GPG Key ID: CB2454984587B781
2 changed files with 4 additions and 8 deletions

2
dist/worker.js vendored

File diff suppressed because one or more lines are too long

View File

@ -33,10 +33,6 @@ async function handler(type, request) {
const url = new URL(request.url)
const id = url.pathname.split('/')[2]
if (id === "") {
return new Response('ID needs to be specified', { status: 400, headers: { 'content-type': 'text/plain' } })
}
format = url.searchParams.get('f')
if (format === null) {
format = '320'
@ -237,9 +233,9 @@ async function m3u8(type, id, format, access_token, tagging, host) {
async function handleRequest(request) {
const r = new Router()
r.get('/track/.*', () => handler('track', request))
r.get('/album/.*', () => handler('album', request))
r.get('/playlist/.*', () => handler('playlist', request))
r.get('/track/-?\\d+', () => handler('track', request))
r.get('/album/\\d+', () => handler('album', request))
r.get('/playlist/\\d+', () => handler('playlist', request))
const resp = await r.route(request)
return resp