rdilweb / docusaurus-plugin-remote-content

A Docusaurus plugin to download content from remote sources when it is needed.
MIT License
94 stars 12 forks source link

Fix issue with double slashes in URL #31

Closed essential-randomness closed 2 years ago

essential-randomness commented 2 years ago

In index.ts, sourceBaseUrl gets a "/" added at the end if not already present, but in findCollectables the url is defined as ${sourceBaseUrl}/${d}, causing a double slash in URLs.

The URLs in the current examples do not trigger an error when multiple forward slashes are present. For example, this is a valid URL: https://raw.githubusercontent.com/PowerShell/PowerShell/master////////////README.md

I added an example that does trigger an error using the GitHub API for the issue labels in this same repository: https://api.github.com/repos/rdilweb/docusaurus-plugin-remote-content/labels.

This also serves as a way to document how to use this plugin for fetching data from this API, as it requires responseType: "arraybuffer" in its config to work (or it's interpreted as a JSON array, which cannot be serialized to file using the current method).

RDIL commented 2 years ago

Looks good, thank you!