Merge pull request #7 from Ovyerus/fix/trailing-slash
fix: trim trailing slash from path
This commit is contained in:
commit
cf1c7edc9c
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
|
||||
}
|
||||
|
||||
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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue