strapi-plugin-documentation
Version:
This is the description of the plugin.
19 lines (15 loc) • 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;