Skip to content

Commit

Permalink
fix: just omit discord non-channel url (#149)
Browse files Browse the repository at this point in the history
closes: #147
  • Loading branch information
cm-ayf authored Jan 14, 2024
1 parent cc83229 commit 7d225f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/synthesis/clean.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ test("cleanMarkdown works fine with url", () => {
expect(cleanMarkdown(mockMessage("https://www.example.com"))).toBe(
" URL省略 ",
);
expect(
cleanMarkdown(mockMessage("https://discord.com/developers/docs/intro")),
).toBe(" URL省略 ");
expect(cleanMarkdown(mockMessage("https://discord.com/channels/0/0"))).toBe(
" 外部サーバーのチャンネル ",
);
Expand Down
4 changes: 2 additions & 2 deletions src/synthesis/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ function parseDiscordUrl(url: string): DiscordUrl | undefined {
if (protocol !== "https:") return;
if (!["discord.com", "canary.discord.com"].includes(host)) return;

const [, , guildId, channelId, messageId] = pathname.split("/");
if (!guildId || !channelId) return;
const [, channels, guildId, channelId, messageId] = pathname.split("/");
if (channels !== "channels" || !guildId || !channelId) return;

return { guildId, channelId, messageId };
// eslint-disable-next-line no-empty
Expand Down

0 comments on commit 7d225f8

Please sign in to comment.