remark-embedder / transformer-oembed

@remark-embedder transformer for oEmbed supported links
MIT License
35 stars 3 forks source link

`{format}` parameter in oembed URL is not replaced by actual format (json) #26

Open vlisivka opened 3 years ago

vlisivka commented 3 years ago

Problem description:

This plugin doesn't replace {format} parameter in oembed URL.

Expected URL:

https://vimeo.com/api/oembed.json?URL

Actual URL:

https://vimeo.com/api/oembed.%7Bformat%7D?URL

Error message:

(node:169898) UnhandledPromiseRejectionWarning: FetchError: The following error occurred while processing `https://vimeo.com/66520064` with the remark-embedder transformer `@remark-embedder/transformer-oembed`:

invalid json response body at https://vimeo.com/api/oembed.%7Bformat%7D?url=https%3A%2F%2Fvimeo.com%2F66520064&maxwidth=640&maxheight=480&format=json reason: Unexpected token < in JSON at position 0
    at /home/vlisivka/workspace/vlisivka.github.io/node_modules/minipass-fetch/lib/body.js:77:31
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Object.getHTML (/home/vlisivka/workspace/vlisivka.github.io/node_modules/@remark-embedder/transformer-oembed/dist/index.js:87:18)
    at async /home/vlisivka/workspace/vlisivka.github.io/node_modules/@remark-embedder/core/dist/index.js:106:20
    at async Promise.all (index 8)
    at async /home/vlisivka/workspace/vlisivka.github.io/node_modules/@remark-embedder/core/dist/index.js:158:5

Suggested solution:

Replace {format} by json.

kentcdodds commented 3 years ago

Hi @vlisivka,

Thanks for the issue. If you'd like to dig a little deeper into things and make a pull request that'd be great. Thanks!