diff --git a/src/slack/commands/list.ts b/src/slack/commands/list.ts index 3dd5a82..bbf5b02 100644 --- a/src/slack/commands/list.ts +++ b/src/slack/commands/list.ts @@ -1,4 +1,4 @@ -import { eq } from 'drizzle-orm' +import { eq, sql } from 'drizzle-orm' import { buildListBlocks } from '@bot/blocks/list' import { db } from '@db/client' import { repositories, subscriptions } from '@db/schema' @@ -21,6 +21,10 @@ export async function handleList( .from(subscriptions) .innerJoin(repositories, eq(subscriptions.repositoryId, repositories.id)) .where(eq(subscriptions.channelId, ctx.channelId)) + .orderBy( + sql`lower(${repositories.owner})`, + sql`lower(${repositories.repo})`, + ) if (rows.length === 0) { await ctx.respond( diff --git a/src/slack/commands/parse.test.ts b/src/slack/commands/parse.test.ts index b5ec36d..903b47b 100644 --- a/src/slack/commands/parse.test.ts +++ b/src/slack/commands/parse.test.ts @@ -49,4 +49,11 @@ describe('parseRepo', () => { test('returns null for empty string', () => { expect(parseRepo('')).toBeNull() }) + + test('lowercases owner and repo', () => { + expect(parseRepo('Torvalds/Linux')).toEqual({ + owner: 'torvalds', + name: 'linux', + }) + }) }) diff --git a/src/slack/commands/parse.ts b/src/slack/commands/parse.ts index 17866e5..8f4440c 100644 --- a/src/slack/commands/parse.ts +++ b/src/slack/commands/parse.ts @@ -15,5 +15,8 @@ export function parseRepo(arg: string): { owner: string; name: string } | null { } const idx = arg.indexOf('/') - return { owner: arg.slice(0, idx), name: arg.slice(idx + 1) } + return { + owner: arg.slice(0, idx).toLowerCase(), + name: arg.slice(idx + 1).toLowerCase(), + } }