Unable to decode URI for Chinese characters in a URL in Gatsby

326 views Asked by At

I'm using Gatsby with Strapi as a headless CMS for a multi-lingual blog. It appears that in some (not all) of the Chinese blog posts the slug arrives encoded. I attempted to use the following:

const decodeSlug = (slug.includes("%")) ? decodeURIComponent(slug) : slug

Even after decoding, Gatsby isn't able to find the post because it comes through like this:

There's not a page yet at /zh-hant/%E8%8A%AF%E5%9F%9F%E7%9F%BF%E6%B1%A0%EF%BC%9A%E6%9C%80%E6%96%B0%E7%9A%84mxc%E6%9E%81%E5%9F%9F%E8%B6%85%E7%BA%A7%E8%8A%82%E7%82%B9

I've worked on troubleshooting it for some time, but haven't found the solution.

You can find the whole blog here: https://github.com/mxc-foundation/mxc-blog

I'm attempting to place the decode in the PostRow.js component:

src/components/Globals/PostRow.js
0

There are 0 answers