JSFiddle - React, Tailwind, and code Playground

HTML

<a href="http://fiddle.jshell.net">http://fiddle.jshell.net</a>
<a href="https://fiddle.jshell.net">https://fiddle.jshell.net</a>
<a href="//fiddle.jshell.net">//fiddle.jshell.net</a>
<a href="http://fiddle.jshell.net/">http://fiddle.jshell.net/</a>

<a href="http://example.org">http://example.org</a>

JavaScript

$(function(){


    $(document).on('click', 'a', function(e) {
        // abort if any key was pressed, let browsers handle that!
        if (e.shiftKey || e.ctrlKey || e.metaKey) {
            return;
        }
        // allow links to the same host (including port) for http, https

        var p =  new RegExp('^(https?:)?\\\/\\\/' + location.host.replace('.', '\\\.') + '($|\\\/)');
        if (!p.exec(this.href)) {
            // prevent browser from doing its regular link handling
            e.preventDefault();
            // open the link in a new window
            console.log("juhuuu");
            window.open(this.href, '_blank');
        }
    });

});