gatsby-source-prismic
Version:
Gatsby source plugin for building websites using Prismic as a data source
14 lines (13 loc) • 386 B
text/typescript
/**
* Sanitizes an image URL. The following steps are taken:
*
* - Replace `+` in filename with a space
* - Decode the URL
*
* @param url - Image URL to sanitize.
*
* @returns Sanitized image URL.
*/
// TODO: Remove once the Prismic API properly handles spaces in filenames
export const sanitizeImageURL = (url: string): string =>
decodeURIComponent(url.replace(/\+/g, " "));