fix: trim trailing slash from path
This commit is contained in:
parent
4fd6710a1c
commit
9dd6b358fa
1 changed files with 4 additions and 2 deletions
6
index.js
6
index.js
|
|
@ -17,8 +17,10 @@ async function handleRequest(event) {
|
||||||
secret = WORKERLINKS_SECRET
|
secret = WORKERLINKS_SECRET
|
||||||
}
|
}
|
||||||
|
|
||||||
var key = new URL(request.url).pathname
|
let path = new URL(request.url).pathname
|
||||||
var shorturl = new URL(request.url).origin + key
|
// Trim trailing slash
|
||||||
|
let key = path !== '/' ? path.replace(/\/$/, '') : path;
|
||||||
|
let shorturl = new URL(request.url).origin + key
|
||||||
|
|
||||||
if (request.method == 'PUT') {
|
if (request.method == 'PUT') {
|
||||||
return await putLink(
|
return await putLink(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue