discord / discord-api-docs

Official Discord API Documentation
https://discord.com/developers/docs/intro
Other
5.95k stars 1.26k forks source link

Article embeds not getting parsed if the pathname matches "/invite/*" #7103

Open DEVTomatoCake opened 1 month ago

DEVTomatoCake commented 1 month ago

Description

If a website URL matches <base>/invite/<some text>, its embeds aren't parsed by the API.

This is probably related to Discord invites matching https://discord.com/invite/<code>, however, it also breaks the embed of unrelated websites.

Steps to Reproduce

Send the following message on Discord:

https://embedtest.tomatocake.workers.dev/
https://embedtest.tomatocake.workers.dev/test
https://embedtest.tomatocake.workers.dev/invite
https://embedtest.tomatocake.workers.dev/invite/test
https://embedtest.tomatocake.workers.dev/invite/test/test2

The worker running behind it always returns the current pathname as article description:

export default {
    async fetch(request, env, ctx) {
        const parsed = new URL(request.url)
        return new Response("<meta property='og:description' content='" + parsed.pathname + "'>", {
            headers: {
                "Content-Type": "text/html"
            }
        })
    }
}

Expected Behavior

All five links have an embed with their path name.

Current Behavior

The fourth link, https://embedtest.tomatocake.workers.dev/invite/test, doesn't show any embed. It also doesn't have an entry in the embeds array of the message, suggesting an API instead of a client issue.

The embed debugger in the Developer Portal however displays the embed correctly: https://discord.com/developers/embeds?url=https%253A%252F%252Fembedtest.tomatocake.workers.dev%252Finvite%252Ftest

Screenshots/Videos

image

Client and System Information

canary 321657 (4acf674) Host 1.0.435 x64 (51461) Build Override: N/A Windows 11 64-bit (10.0.22631)

Rodentman87 commented 15 hours ago

I'm not able to reproduce this behavior at all, are you still seeing this on your end? I tried to reproduce with a web server that matches yours (responds with the meta tag), and it embedded properly for all five pathnames.