<commit_before>/*global Autolinker, _, describe, beforeEach, afterEach, it, expect */
describe( "Autolinker", function() {
	
	describe( "instantiating and using as a class", function() {
		
		it( "should configure the instance with configuration options, and then be able to execute the link() method", function() {
			var autolinker = new Autolinker( { newWindow: false, truncate: 25 } );
		
			var result = autolinker.link( "Check out http://www.yahoo.com/some/long/path/to/a/file" );
			expect( result ).toBe( 'Check out <a href="http://www.yahoo.com/some/long/path/to/a/file">yahoo.com/some/long/pat..</a>' );
		} );
		
	} );
	
	
	describe( "link() method", function() {
		var autolinker;
		
		beforeEach( function() {
			autolinker = new Autolinker( { newWindow: false } );  // so that target="_blank" is not added to resulting autolinked URLs
		} );
		
		
		describe( "URL linking", function() {
			
			describe( "protocol-prefixed URLs (i.e. URLs starting with http:// or https://)", function() {
		
				it( "should automatically link URLs in the form of http://yahoo.com", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com" );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>' );
				} );
			
			
				it( "should automatically link URLs in the form of http://www.yahoo.com (i.e. protocol and 'www' prefix)", function() {
					var result = autolinker.link( "Joe went to http://www.yahoo.com" );
					expect( result ).toBe( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>' );
				} );
			
			
				it( "should automatically link https URLs in the form of https://yahoo.com", function() {
					var result = autolinker.link( "Joe went to https://www.yahoo.com" );
					expect( result ).toBe( 'Joe went to <a href="https://www.yahoo.com">yahoo.com</a>' );
				} );
				
				
				it( "should automatically link capitalized URLs", function() {
					var result = autolinker.link( "Joe went to HTTP://WWW.YAHOO.COM" );
					expect( result ).toBe( 'Joe went to <a href="HTTP://WWW.YAHOO.COM">YAHOO.COM</a>' );
				} );
				
				
				it( "should automatically link 'yahoo.xyz' (a known TLD), but not 'sencha.etc' (an unknown TLD)", function() {
					var result = autolinker.link( "yahoo.xyz should be linked, sencha.etc should not", { newWindow: false } );
					expect( result ).toBe( '<a href="http://yahoo.xyz">yahoo.xyz</a> should be linked, sencha.etc should not' );
				} );
				
				
				it( "should automatically link 'a.museum' (a known TLD), but not 'abc.123'", function() {
					var result = autolinker.link( "a.museum should be linked, but abc.123 should not", { newWindow: false } );
					expect( result ).toBe( '<a href="http://a.museum">a.museum</a> should be linked, but abc.123 should not' );
				} );
		
		
				it( "should automatically link URLs in the form of 'http://yahoo.com.', without including the trailing period", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com." );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>.' );
				} );
				
				
				it( "should automatically link URLs with a port number", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com:8000 today." );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000">yahoo.com:8000</a> today.' );
				} );
				
				
				it( "should automatically link URLs with a port number and a following slash", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com:8000/ today." );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000/">yahoo.com:8000</a> today.' );
				} );
				
				
				it( "should automatically link URLs with a port number and a path", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com:8000/mysite/page today." );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000/mysite/page">yahoo.com:8000/mysite/page</a> today.' );
				} );
				
				
				it( "should automatically link URLs with a port number and a query string", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com:8000?page=index today." );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000?page=index">yahoo.com:8000?page=index</a> today.' );
				} );
				
				
				it( "should automatically link URLs with a port number and a hash string", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com:8000#page=index today." );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000#page=index">yahoo.com:8000#page=index</a> today.' );
				} );
				
				
				it( "should NOT automatically link strings of the form 'git:d' (using the heuristic that the domain name does not have a '.' in it)", function() {
					var result = autolinker.link( 'Something like git:d should not be linked as a URL' );
					expect( result ).toBe( 'Something like git:d should not be linked as a URL' );
				} );
				
				
				it( "should NOT automatically link strings of the form 'git:domain' (using the heuristic that the domain name does not have a '.' in it)", function() {
					var result = autolinker.link( 'Something like git:domain should not be linked as a URL' );
					expect( result ).toBe( 'Something like git:domain should not be linked as a URL' );
				} );
				
				
				it( "should automatically link strings of the form 'git:domain.com', interpreting this as a protocol and domain name", function() {
					var result = autolinker.link( 'Something like git:domain.com should be linked as a URL' );
					expect( result ).toBe( 'Something like <a href="git:domain.com">git:domain.com</a> should be linked as a URL' );
				} );
				
				
				it( "should NOT automatically link a string in the form of 'version:1.0'", function() {
					var result = autolinker.link( 'version:1.0' );
					expect( result ).toBe( 'version:1.0' );
				} );
				
				
				it( "should NOT automatically link these 'abc:def' style strings", function() {
					var strings = [
						'BEGIN:VCALENDAR',
						'VERSION:1.0',
						'BEGIN:VEVENT',
						'DTSTART:20140401T090000',
						'DTEND:20140401T100000',
						'SUMMARY:Some thing to do',
						'LOCATION:',
						'DESCRIPTION:Just call this guy yeah! Testings',
						'PRIORITY:3',
						'END:VEVENT',
						'END:VCALENDAR'
					];
					
					for( var i = 0, len = strings.length; i < len; i++ ) {
						expect( autolinker.link( strings[ i ] ) ).toBe( strings[ i ] );  // none should be autolinked
					}
				} );
				
			} );
			
			
			describe( "'www.' prefixed URLs", function() {
		
				it( "should automatically link URLs in the form of www.yahoo.com, prepending the http:// in this case", function() {
					var result = autolinker.link( "Joe went to www.yahoo.com" );
					expect( result ).toBe( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>' );
				} );
				<commit_msg>Add a (failing) test for preceding colon linking<commit_after>/*global Autolinker, _, describe, beforeEach, afterEach, it, expect */
describe( "Autolinker", function() {
	
	describe( "instantiating and using as a class", function() {
		
		it( "should configure the instance with configuration options, and then be able to execute the link() method", function() {
			var autolinker = new Autolinker( { newWindow: false, truncate: 25 } );
		
			var result = autolinker.link( "Check out http://www.yahoo.com/some/long/path/to/a/file" );
			expect( result ).toBe( 'Check out <a href="http://www.yahoo.com/some/long/path/to/a/file">yahoo.com/some/long/pat..</a>' );
		} );
		
	} );
	
	
	describe( "link() method", function() {
		var autolinker;
		
		beforeEach( function() {
			autolinker = new Autolinker( { newWindow: false } );  // so that target="_blank" is not added to resulting autolinked URLs
		} );
		
		
		describe( "URL linking", function() {
			
			describe( "protocol-prefixed URLs (i.e. URLs starting with http:// or https://)", function() {
		
				it( "should automatically link URLs in the form of http://yahoo.com", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com" );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>' );
				} );
			
			
				it( "should automatically link URLs in the form of http://www.yahoo.com (i.e. protocol and 'www' prefix)", function() {
					var result = autolinker.link( "Joe went to http://www.yahoo.com" );
					expect( result ).toBe( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>' );
				} );
			
			
				it( "should automatically link https URLs in the form of https://yahoo.com", function() {
					var result = autolinker.link( "Joe went to https://www.yahoo.com" );
					expect( result ).toBe( 'Joe went to <a href="https://www.yahoo.com">yahoo.com</a>' );
				} );
				
				
				it( "should automatically link capitalized URLs", function() {
					var result = autolinker.link( "Joe went to HTTP://WWW.YAHOO.COM" );
					expect( result ).toBe( 'Joe went to <a href="HTTP://WWW.YAHOO.COM">YAHOO.COM</a>' );
				} );
				
				
				it( "should automatically link 'yahoo.xyz' (a known TLD), but not 'sencha.etc' (an unknown TLD)", function() {
					var result = autolinker.link( "yahoo.xyz should be linked, sencha.etc should not", { newWindow: false } );
					expect( result ).toBe( '<a href="http://yahoo.xyz">yahoo.xyz</a> should be linked, sencha.etc should not' );
				} );
				
				
				it( "should automatically link 'a.museum' (a known TLD), but not 'abc.123'", function() {
					var result = autolinker.link( "a.museum should be linked, but abc.123 should not", { newWindow: false } );
					expect( result ).toBe( '<a href="http://a.museum">a.museum</a> should be linked, but abc.123 should not' );
				} );
		
		
				it( "should automatically link URLs in the form of 'http://yahoo.com.', without including the trailing period", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com." );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com">yahoo.com</a>.' );
				} );
				
				
				it( "should automatically link URLs with a port number", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com:8000 today." );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000">yahoo.com:8000</a> today.' );
				} );
				
				
				it( "should automatically link URLs with a port number and a following slash", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com:8000/ today." );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000/">yahoo.com:8000</a> today.' );
				} );
				
				
				it( "should automatically link URLs with a port number and a path", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com:8000/mysite/page today." );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000/mysite/page">yahoo.com:8000/mysite/page</a> today.' );
				} );
				
				
				it( "should automatically link URLs with a port number and a query string", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com:8000?page=index today." );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000?page=index">yahoo.com:8000?page=index</a> today.' );
				} );
				
				
				it( "should automatically link URLs with a port number and a hash string", function() {
					var result = autolinker.link( "Joe went to http://yahoo.com:8000#page=index today." );
					expect( result ).toBe( 'Joe went to <a href="http://yahoo.com:8000#page=index">yahoo.com:8000#page=index</a> today.' );
				} );
				
				
				it( "should NOT automatically link strings of the form 'git:d' (using the heuristic that the domain name does not have a '.' in it)", function() {
					var result = autolinker.link( 'Something like git:d should not be linked as a URL' );
					expect( result ).toBe( 'Something like git:d should not be linked as a URL' );
				} );
				
				
				it( "should NOT automatically link strings of the form 'git:domain' (using the heuristic that the domain name does not have a '.' in it)", function() {
					var result = autolinker.link( 'Something like git:domain should not be linked as a URL' );
					expect( result ).toBe( 'Something like git:domain should not be linked as a URL' );
				} );
				
				
				it( "should automatically link strings of the form 'git:domain.com', interpreting this as a protocol and domain name", function() {
					var result = autolinker.link( 'Something like git:domain.com should be linked as a URL' );
					expect( result ).toBe( 'Something like <a href="git:domain.com">git:domain.com</a> should be linked as a URL' );
				} );
				
				
				it( "should NOT automatically link a string in the form of 'version:1.0'", function() {
					var result = autolinker.link( 'version:1.0' );
					expect( result ).toBe( 'version:1.0' );
				} );
				
				
				it( "should NOT automatically link these 'abc:def' style strings", function() {
					var strings = [
						'BEGIN:VCALENDAR',
						'VERSION:1.0',
						'BEGIN:VEVENT',
						'DTSTART:20140401T090000',
						'DTEND:20140401T100000',
						'SUMMARY:Some thing to do',
						'LOCATION:',
						'DESCRIPTION:Just call this guy yeah! Testings',
						'PRIORITY:3',
						'END:VEVENT',
						'END:VCALENDAR'
					];
					
					for( var i = 0, len = strings.length; i < len; i++ ) {
						expect( autolinker.link( strings[ i ] ) ).toBe( strings[ i ] );  // none should be autolinked
					}
				} );

				it( "should NOT include preceding : introductions without a space", function() {
					var result = autolinker.link( 'the link:http://example.com/' );
					expect( result ).toBe( 'the link:<a href="http://example.com/">example.com/</a>' );
				});
				
			} );
			
			
			describe( "'www.' prefixed URLs", function() {
		
				it( "should automatically link URLs in the form of www.yahoo.com, prepending the http:// in this case", function() {
					var result = autolinker.link( "Joe went to www.yahoo.com" );
					expect( result ).toBe( 'Joe went to <a href="http://www.yahoo.com">yahoo.com</a>' );
				} );
				
{'fraction_non_alphanumeric': 0.15495853122563266, 'fraction_numerical': 0.015453321046289076, 'mean_word_length': 2.928710665552771, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 65, 'https://': 8, 'lorem ipsum': 0, 'www.': 24, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7522814', 'n_tokens_mistral': 5723, 'n_tokens_neox': 4285, 'n_words': 1446}