chore: pre-check if slug is same before and after lowercase.

This commit is contained in:
ZL Asica 2024-12-06 15:11:07 -06:00
parent 902fc1bef5
commit 899323faf6
No known key found for this signature in database
GPG key ID: 5B1ED5BE09CE4C01

View file

@ -20,8 +20,9 @@ export default eventHandler(async (event) => {
await KV.get(`link:${key}`, { type: 'json', cacheTtl: linkCacheTtl })
link = await getLink(slug)
if (!caseSensitive && !link) {
link = await getLink(slug.toLowerCase())
const lowercaseSlug = slug.toLowerCase()
if (!caseSensitive && !link && lowercaseSlug !== slug) {
link = await getLink(lowercaseSlug)
}
if (link) {