mirror of
https://github.com/strapi/strapi.git
synced 2025-08-02 22:07:11 +00:00
19 lines
427 B
JavaScript
19 lines
427 B
JavaScript
![]() |
import { startsWith } from 'lodash';
|
||
|
|
||
|
const openWithNewTab = (path) => {
|
||
|
const url = (() => {
|
||
|
if (startsWith(path, '/')) {
|
||
|
return `${strapi.backendURL}${path}`;
|
||
|
} else if (startsWith(path, 'https') || startsWith(path, 'http')) {
|
||
|
return path;
|
||
|
} else {
|
||
|
return `${strapi.backendURL}/${path}`;
|
||
|
}
|
||
|
})();
|
||
|
|
||
|
window.open(url, '_blank');
|
||
|
|
||
|
return window.focus();
|
||
|
};
|
||
|
|
||
|
export default openWithNewTab;
|