Skip to content

Commit 0a5478e

Browse files
moved prefixFileUrlWithBackendUrl in its own file
1 parent 5964441 commit 0a5478e

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

admin/src/components/MediaLib.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { useStrapiApp } from '@strapi/strapi/admin';
4+
import prefixFileUrlWithBackendUrl from '../utils/prefixFileUrlWithBackendUrl';
45

5-
const prefixFileUrlWithBackendUrl = (fileURL: string) => {
6-
return !!fileURL &&
7-
fileURL.startsWith("/") &&
8-
"strapi" in window &&
9-
window.strapi instanceof Object &&
10-
"backendURL" in window.strapi &&
11-
window.strapi.backendURL
12-
? `${window.strapi.backendURL}${fileURL}`
13-
: fileURL;
14-
};
156

167
const MediaLib = ( { isOpen = false, onChange = () => {}, onToggle = () => {} } ) => {
178
const { components } = useStrapiApp( 'library', app => app );
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const prefixFileUrlWithBackendUrl = (fileURL: string) => {
2+
return !!fileURL &&
3+
fileURL.startsWith("/") &&
4+
"strapi" in window &&
5+
window.strapi instanceof Object &&
6+
"backendURL" in window.strapi &&
7+
window.strapi.backendURL
8+
? `${window.strapi.backendURL}${fileURL}`
9+
: fileURL;
10+
};
11+
12+
export default prefixFileUrlWithBackendUrl;

0 commit comments

Comments
 (0)