Autolinker.js icon indicating copy to clipboard operation
Autolinker.js copied to clipboard

Don't link shell scripts.

Open abacon opened this issue 9 years ago • 0 comments

Because .sh is a TLD, autolinker matches some string like ./myShellScript.sh and links it. This isn't great. I'm not sure what the best way to go about omitting shell scripts is — should we use an option to ignore all content of <pre> or <code> tags? Or perhaps just not match strings that are prefixed with ./.

What do y'all think?

I've reproduced below a brief testcase I wrote for inclusion in autoLinkerSpec.js. :) Hopefully you find it useful.

    it( "should automatically link 'mywebsite.sh' (a known TLD) but not './myscript.sh' (a shell script)", function() {
        var result = autolinker.link( "mywebsite.sh should be linked, ./myscript.sh should not", { newWindow: false } );
        expect( result ).toBe( '<a href="http://mywebsite.sh">mywebsite.sh</a> should be linked, ./myscript.sh should not' );
    } );

abacon avatar Jun 22 '16 23:06 abacon