mirror of
https://github.com/strapi/strapi.git
synced 2025-07-31 04:45:54 +00:00
21 lines
411 B
JavaScript
Executable File
21 lines
411 B
JavaScript
Executable File
import { startsWith } from 'lodash';
|
|
|
|
const openWithNewTab = path => {
|
|
const url = (() => {
|
|
if (startsWith(path, '/')) {
|
|
return `${strapi.backendURL}${path}`;
|
|
}
|
|
if (startsWith(path, 'https') || startsWith(path, 'http')) {
|
|
return path;
|
|
}
|
|
|
|
return `${strapi.backendURL}/${path}`;
|
|
})();
|
|
|
|
window.open(url, '_blank');
|
|
|
|
return window.focus();
|
|
};
|
|
|
|
export default openWithNewTab;
|