2018-12-06 18:03:56 +01:00
|
|
|
import { startsWith } from 'lodash';
|
|
|
|
|
2020-01-21 16:03:31 +01:00
|
|
|
const openWithNewTab = path => {
|
2018-12-06 18:03:56 +01:00
|
|
|
const url = (() => {
|
|
|
|
if (startsWith(path, '/')) {
|
|
|
|
return `${strapi.backendURL}${path}`;
|
2020-01-21 16:31:05 +01:00
|
|
|
}
|
|
|
|
if (startsWith(path, 'https') || startsWith(path, 'http')) {
|
2018-12-06 18:03:56 +01:00
|
|
|
return path;
|
|
|
|
}
|
2020-01-21 16:31:05 +01:00
|
|
|
|
2020-01-21 16:03:31 +01:00
|
|
|
return `${strapi.backendURL}/${path}`;
|
2018-12-06 18:03:56 +01:00
|
|
|
})();
|
|
|
|
|
|
|
|
window.open(url, '_blank');
|
|
|
|
|
|
|
|
return window.focus();
|
|
|
|
};
|
|
|
|
|
2020-01-21 16:03:31 +01:00
|
|
|
export default openWithNewTab;
|