Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Territory links are case-sensitive #703

Closed
ekzyis opened this issue Dec 22, 2023 · 1 comment
Closed

Territory links are case-sensitive #703

ekzyis opened this issue Dec 22, 2023 · 1 comment
Assignees
Labels

Comments

@ekzyis
Copy link
Member

ekzyis commented Dec 22, 2023

Description

Territories links are case-sensitive. This means that https://stacker.news/~Psychedelics works but https://stacker.news/~psychedelics does not.

Steps to Reproduce

Click on https://stacker.news/~psychedelics -> 404
Click on https://stacker.news/~Psychedelics -> 200

Expected behavior

Both links should work.

Additional context

Since we use citext, we already made sure that all queries hitting Sub.name are implicitly case-insensitive. This means we already made sure that territories with different cases cannot be created. But for some reason, the links are still case-sensitive.

https://stacker.news/items/361271

@ekzyis ekzyis added the bug label Dec 22, 2023
@ekzyis ekzyis self-assigned this Dec 22, 2023
@ekzyis
Copy link
Member Author

ekzyis commented Dec 22, 2023

For some reason, the sub resolver seems to not be case-insensitive. With the following patch, https://stacker.news/~psychedelics finds the sub but other queries seem to fail (since the dropdown does not reflect the sub we're in)

diff --git a/api/resolvers/sub.js b/api/resolvers/sub.js
index 5d8923d..65063bd 100644
--- a/api/resolvers/sub.js
+++ b/api/resolvers/sub.js
@@ -76,9 +76,12 @@ export default {
         }).catch(console.log)
       }

-      return await models.sub.findUnique({
+      return await models.sub.findFirst({
         where: {
-          name
+          name: {
+            equals: name,
+            mode: 'insensitive'
+          }
         }
       })
     },
video
2023-12-22.11-44-02.mp4

But Prisma seems to be aware of citext ...

@huumn huumn closed this as completed in 8996fd0 Jan 3, 2024
huumn added a commit that referenced this issue Jan 4, 2024
This reverts commit 8996fd0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant