validate path first before GET and HEAD

This commit is contained in:
Peter Cai 2021-11-24 18:58:50 -05:00
parent c682455d46
commit 1af297c537
1 changed files with 6 additions and 0 deletions

View File

@ -20,6 +20,9 @@ handleRequest = ({ request }) ->
handleHEAD = (request) ->
url = new URL request.url
if url.pathname.endsWith "/"
return new Response "Invalid URL",
status: 404
resp = await s3.getObject url.pathname[1...], {}
@ -30,6 +33,9 @@ handleHEAD = (request) ->
handleGET = (request) ->
url = new URL request.url
if url.pathname.endsWith "/"
return new Response "Invalid URL",
status: 404
return await s3.getObject url.pathname[1...], {}