soupette eb00b7e0ea Add newline-before-return rule
Signed-off-by: soupette <cyril.lpz@gmail.com>
2020-01-21 16:31:05 +01:00

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;