edited regex on router stuff
This commit is contained in:
parent
396c662ef3
commit
756221a4b1
File diff suppressed because one or more lines are too long
10
index.js
10
index.js
|
@ -33,10 +33,6 @@ async function handler(type, request) {
|
||||||
const url = new URL(request.url)
|
const url = new URL(request.url)
|
||||||
const id = url.pathname.split('/')[2]
|
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')
|
format = url.searchParams.get('f')
|
||||||
if (format === null) {
|
if (format === null) {
|
||||||
format = '320'
|
format = '320'
|
||||||
|
@ -237,9 +233,9 @@ async function m3u8(type, id, format, access_token, tagging, host) {
|
||||||
|
|
||||||
async function handleRequest(request) {
|
async function handleRequest(request) {
|
||||||
const r = new Router()
|
const r = new Router()
|
||||||
r.get('/track/.*', () => handler('track', request))
|
r.get('/track/-?\\d+', () => handler('track', request))
|
||||||
r.get('/album/.*', () => handler('album', request))
|
r.get('/album/\\d+', () => handler('album', request))
|
||||||
r.get('/playlist/.*', () => handler('playlist', request))
|
r.get('/playlist/\\d+', () => handler('playlist', request))
|
||||||
|
|
||||||
const resp = await r.route(request)
|
const resp = await r.route(request)
|
||||||
return resp
|
return resp
|
||||||
|
|
Loading…
Reference in New Issue