chaijs / chaijs.github.io

The chaijs.com website source code. Contributions welcome.
http://chaijs.github.io
49 stars 71 forks source link

Plugin links with scope are broken #212

Closed HeyITGuyFixIt closed 3 months ago

HeyITGuyFixIt commented 3 months ago

I get a 404 when opening a plugin link that contains a scope, such as @faltest/chai which links to https://www.chaijs.com/plugins/@faltest/chai/. The permalink is supposed to be plugins/@faltest/chai/.

When looking at the generated md file, GitHub shows this error:

Error in user YAML: (<unknown>): found character that cannot start any token while scanning for the next token at line 3 column 13

I am guessing it doesn't like the @. It needs to be escaped. encodeURI won't encode the @, and encodeURIComponent turns @faltest/chai into %40faltest%2Fchai.

HeyITGuyFixIt commented 3 months ago

This line:

https://github.com/chaijs/chaijs.github.io/blob/9f52c6b0b9658e7fed329a3b2420394ac048fecf/_scripts/build-plugin-pages.js#L9

could be changed to

    var contents = '---\nlayout: plugin\npermalink: plugins/' + encodeURIComponent(pluginJson.name) + '/\npluginName: ' + encodeURIComponent(pluginJson.name) + '\n---\n\n' + pluginJson.readme;

if you want to use encodeURIComponent.

keithamus commented 3 months ago

PRs welcome!