/**
 * Secures outbound links. For more info:
 * https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/
 */
import filter from 'lodash/filter';
import { isDomainSecure } from '../url';
export const getSecureRelForTarget = ({ href, target, rel, }) => {
    if (!target || !target.includes('_blank')) {
        return rel;
    }
    const isElasticHref = !!href && isDomainSecure(href);
    const relParts = !!rel
        ? filter(rel.split(' '), part => !!part.length && part !== 'noreferrer')
        : [];
    if (relParts.indexOf('noopener') === -1) {
        relParts.push('noopener');
    }
    if (!isElasticHref) {
        relParts.push('noreferrer');
    }
    return relParts
        .sort()
        .join(' ')
        .trim();
};
//# sourceMappingURL=get_secure_rel_for_target.js.map