mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 23:57:32 +00:00
20 lines
359 B
JavaScript
Executable File
20 lines
359 B
JavaScript
Executable File
const openWithNewTab = (path) => {
|
|
const url = (() => {
|
|
if (path.startsWith('/')) {
|
|
return `${window.strapi.backendURL}${path}`;
|
|
}
|
|
|
|
if (path.startsWith('http')) {
|
|
return path;
|
|
}
|
|
|
|
return `${window.strapi.backendURL}/${path}`;
|
|
})();
|
|
|
|
window.open(url, '_blank');
|
|
|
|
return window.focus();
|
|
};
|
|
|
|
export default openWithNewTab;
|