<commit_before>var godocPrefix = 'http://godoc.org';

chrome.browserAction.onClicked.addListener(function() {
	chrome.tabs.getSelected(null, function(tab) {
		var newUrl;
		if (tab.url.substring(0, godocPrefix.length + 1) == godocPrefix + '/') {
			newUrl = 'http://' + tab.url.substr(godocPrefix.length + 1, tab.url.length - godocPrefix.length - 1);
		} else {
			var slashPos = tab.url.indexOf('/');
			newUrl = 'http://godoc.org' + tab.url.substr(slashPos + 1, tab.url.length - slashPos - 1);
		}
		chrome.tabs.create({ 'url': newUrl });
	});
});
<commit_msg>add special handling of github URLs.<commit_after>var godocHostname = 'godoc.org';

function parseURL(url) {
	var parser = document.createElement('a');
	parser.href = url;
	return parser;
}

function transformGitHubURL(parsedURL) {
	var pathname = parsedURL.pathname;
	var pos;
	if ((pos = pathname.indexOf('/tree/master/')) !== -1) {
		pathname = pathname.substring(0, pos) + '/' + pathname.substring(pos + '/tree/master/'.length);
	} else if ((pos = pathname.indexOf('/blob/master/')) !== -1) {
		pathname = pathname.substring(0, pos) + '/' + pathname.substring(pos + '/blob/master/'.length, pathname.lastIndexOf('/'));
	}
	return 'http://' + godocHostname + '/' + parsedURL.hostname + pathname;
}

chrome.browserAction.onClicked.addListener(function() {
	chrome.tabs.getSelected(null, function(tab) {
		var newURL;
		var parsedURL = parseURL(tab.url);
		if (parsedURL.hostname == godocHostname) {
			newURL = 'http:/' + parsedURL.pathname;
		} else {
			if (parsedURL.hostname == 'github.com' || parsedURL.hostname == 'www.github.com') {
				newURL = transformGitHubURL(parsedURL)
			} else {
				newURL = 'http://' + godocHostname + '/' + parsedURL.hostname + parsedURL.pathname;
			}
		}
		chrome.tabs.create({ 'url': newURL });
	});
});

{'fraction_non_alphanumeric': 0.18559556786703602, 'fraction_numerical': 0.00554016620498615, 'mean_word_length': 3.9889502762430937, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '564026', 'n_tokens_mistral': 673, 'n_tokens_neox': 637, 'n_words': 114}