diff --git a/admin/src/components/MediaLib.tsx b/admin/src/components/MediaLib.tsx index 9619e7c..4f6cfcf 100644 --- a/admin/src/components/MediaLib.tsx +++ b/admin/src/components/MediaLib.tsx @@ -1,17 +1,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import { useStrapiApp } from '@strapi/strapi/admin'; +import prefixFileUrlWithBackendUrl from '../utils/prefixFileUrlWithBackendUrl'; -const prefixFileUrlWithBackendUrl = (fileURL: string) => { - return !!fileURL && - fileURL.startsWith("/") && - "strapi" in window && - window.strapi instanceof Object && - "backendURL" in window.strapi && - window.strapi.backendURL - ? `${window.strapi.backendURL}${fileURL}` - : fileURL; -}; const MediaLib = ( { isOpen = false, onChange = () => {}, onToggle = () => {} } ) => { const { components } = useStrapiApp( 'library', app => app ); diff --git a/admin/src/utils/prefixFileUrlWithBackendUrl.ts b/admin/src/utils/prefixFileUrlWithBackendUrl.ts new file mode 100644 index 0000000..e1ed811 --- /dev/null +++ b/admin/src/utils/prefixFileUrlWithBackendUrl.ts @@ -0,0 +1,12 @@ +const prefixFileUrlWithBackendUrl = (fileURL: string) => { + return !!fileURL && + fileURL.startsWith("/") && + "strapi" in window && + window.strapi instanceof Object && + "backendURL" in window.strapi && + window.strapi.backendURL + ? `${window.strapi.backendURL}${fileURL}` + : fileURL; +}; + +export default prefixFileUrlWithBackendUrl;