fixed bug with case sensitivity
This commit is contained in:
parent
df82248ecf
commit
94eb26fa59
|
@ -23,6 +23,6 @@ EOF
|
|||
linkie/path => http://example.comhttp//example.com?2
|
||||
```
|
||||
|
||||
`curl -n -d u=http://example.com linkie/_`, if you provide an underscore as the path linkie will generate a four character path from a-zA-Z. if it has a collision five times in a row it'll return 500.. at that point i'd probably increase the length of the random ids in the function at the top of index.js to 5 or something, and also i should get off the internet because i've generated 52^4 short urls with this service and that's insane
|
||||
`curl -n -d u=http://example.com linkie/_`, if you provide an underscore as the path linkie will generate a four character path from a-z0-9. if it has a collision five times in a row it'll return 500.. at that point i'd probably increase the length of the random ids in the function at the top of index.js to 5 or something, and also i should get off the internet because i've generated 36^4 short urls with this service and that's insane
|
||||
|
||||
See test.py for more usage and test cases
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
function makeid(length) {
|
||||
let result = '';
|
||||
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
const charactersLength = characters.length;
|
||||
let counter = 0;
|
||||
while (counter < length) {
|
||||
|
@ -45,12 +45,14 @@ async function add(host,path,request) {
|
|||
x += 1
|
||||
}
|
||||
}
|
||||
path = path.toLowerCase()
|
||||
await KV.put(path, dest)
|
||||
return new Response(`https://${host}/${path}`, {status:201})
|
||||
}
|
||||
|
||||
async function remove(host,path) {
|
||||
if (!path) return new Response("No path provided",{status:400})
|
||||
path = path.toLowerCase()
|
||||
await KV.delete(path)
|
||||
return new Response(`DELETE https://${host}/${path}`, {status:200})
|
||||
}
|
||||
|
@ -63,6 +65,7 @@ async function get(host,path,auth) {
|
|||
return new Response(paths,{status:200})
|
||||
}
|
||||
if (!path) return Response.redirect("https://aly-smith.carrd.co",301)
|
||||
path = path.toLowerCase()
|
||||
const dest = await KV.get(path)
|
||||
if (dest) return Response.redirect(dest, 302)
|
||||
return new Response("Path not found", {status:404})
|
||||
|
|
Loading…
Reference in a new issue