From d2091494a1be0a2fe1473e9f32a3d32a91bc457e Mon Sep 17 00:00:00 2001 From: Flummi Date: Sat, 21 May 2022 15:03:01 +0000 Subject: [PATCH] fix tags + slugify --- src/inc/routeinc/f0cklib.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/inc/routeinc/f0cklib.mjs b/src/inc/routeinc/f0cklib.mjs index 93654b9..937ff7c 100644 --- a/src/inc/routeinc/f0cklib.mjs +++ b/src/inc/routeinc/f0cklib.mjs @@ -27,7 +27,7 @@ export default { left join "user" on "user".id = favorites.user_id where ${ db.unsafe(modequery) } - ${ tag ? db`and tags.normalized ilike ${'%'+tag+'%'}` : db`` } + ${ tag ? db`and tags.normalized ilike '%' || slugify(${tag}) || '%'` : db`` } ${ o.fav ? db`and "user".user ilike ${'%'+user+'%'}` : db`` } ${ user ? db`and items.username ilike ${'%'+user+'%'}` : db`` } ${ mime ? db`and items.mime ilike ${smime}` : db`` } @@ -60,7 +60,7 @@ export default { left join tags_assign ta on ta.item_id = items.id and (ta.tag_id = 1 or ta.tag_id = 2) where ${ db.unsafe(modequery) } - ${ tag ? db`and tags.normalized ilike ${'%'+tag+'%'}` : db`` } + ${ tag ? db`and tags.normalized ilike '%' || slugify(${tag}) || '%'` : db`` } ${ o.fav ? db`and "user".user ilike ${'%'+user+'%'}` : db`` } ${ user ? db`and items.username ilike ${'%'+user+'%'}` : db`` } ${ mime ? db`and items.mime ilike ${smime}` : db`` } @@ -121,7 +121,7 @@ export default { left join tags_assign ta on ta.item_id = items.id and (ta.tag_id = 1 or ta.tag_id = 2) where ${ db.unsafe(modequery) } - ${ tag ? db`and tags.normalized ilike ${'%'+tag+'%'}` : db`` } + ${ tag ? db`and tags.normalized ilike '%' || slugify(${tag}) || '%'` : db`` } ${ o.fav ? db`and "user".user ilike ${'%'+user+'%'}` : db`` } ${ user ? db`and items.username ilike ${'%'+user+'%'}` : db`` } ${ mime ? db`and items.mime ilike ${smime}` : db`` } @@ -216,7 +216,7 @@ export default { left join "user" on "user".id = favorites.user_id where ${ db.unsafe(modequery) } - ${ tag ? db`and tags.normalized ilike ${'%'+tag+'%'}` : db`` } + ${ tag ? db`and tags.normalized ilike '%' || slugify(${tag}) || '%'` : db`` } ${ o.fav ? db`and "user".user ilike ${'%'+user+'%'}` : db`` } ${ user ? db`and items.username ilike ${'%'+user+'%'}` : db`` } ${ mime ? db`and items.mime ilike ${smime}` : db`` }