diff --git a/index.js b/index.js index 85c0071..3e542b0 100644 --- a/index.js +++ b/index.js @@ -17,8 +17,10 @@ async function handleRequest(event) { secret = WORKERLINKS_SECRET } - var key = new URL(request.url).pathname - var shorturl = new URL(request.url).origin + key + let path = new URL(request.url).pathname + // Trim trailing slash + let key = path !== '/' ? path.replace(/\/$/, '') : path; + let shorturl = new URL(request.url).origin + key if (request.method == 'PUT') { return await putLink(