<commit_before>package DDG::Spice::Bitly;
# ABSTRACT: Return a shortened version of a URL using the bitly API.

use DDG::Spice;

primary_example_queries "bitly http://www.duckduckgo.com/about.html";
secondary_example_queries "shorten http://www.duckduckgo.com/goodies", "url shorten www.github.com/explore";
description "Shorten URLs using the bitly API";
name "Bitly";
icon_url "/i/bitly.com.ico";
source "Bitly";
code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Bitly.pm";
topics "social";
category "computing_tools";
attribution github => ['https://github.com/danjarvis','<NAME>'],
            twitter => ['http://twitter.com/danjarvis','danjarvis'];

spice to => 'http://api.bitly.com/v3/shorten?login=duckduckhack&apiKey={{ENV{DDG_SPICE_BITLY_APIKEY}}}&longUrl=$1://$2&callback={{callback}}';
spice from => '(?:([^/]*)/([^/]*)|)';

triggers start => 'bitly', 'bit.ly', 'shorten', 'shorten url', 'short url', 'url shorten';

handle remainder => sub {
	my ($longUri) = shift;
	if ($longUri) {
		if ($longUri =~ /^(.*?):\/\/(.+)/) {
			return $1, $2;
		} else {
            return "http", $longUri;
        }
	}
	return;
};

1;<commit_msg>Fixed bug that was preventing bit.ly from detecting the URLs path.<commit_after>package DDG::Spice::Bitly;
# ABSTRACT: Return a shortened version of a URL using the bitly API.

use DDG::Spice;

primary_example_queries "bitly http://www.duckduckgo.com/about.html";
secondary_example_queries "shorten http://www.duckduckgo.com/goodies", "url shorten www.github.com/explore";
description "Shorten URLs using the bitly API";
name "Bitly";
icon_url "/i/bitly.com.ico";
source "Bitly";
code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Bitly.pm";
topics "social";
category "computing_tools";
attribution github => ['https://github.com/danjarvis','<NAME>'],
            twitter => ['http://twitter.com/danjarvis','danjarvis'];

spice to => 'http://api.bitly.com/v3/shorten?login=duckduckhack&apiKey={{ENV{DDG_SPICE_BITLY_APIKEY}}}&longUrl=$1://$2&callback={{callback}}';
spice from => '(?:([^/]+)/(.+))';

triggers any => 'bitly', 'bit.ly', 'shorten', 'shorten url', 'short url', 'url shorten';

handle remainder => sub {
	my ($longUri) = shift;
	if ($longUri) {
		if($longUri =~ /(.+):\/\/(.+)/) {
			return $1, $2;
		} else {
            return 'http', $longUri;
        }
	}
	return;
};

1;
{'fraction_non_alphanumeric': 0.20083333333333334, 'fraction_numerical': 0.005, 'mean_word_length': 4.532258064516129, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 4, 'lorem ipsum': 0, 'www.': 6, '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': '7112465', 'n_tokens_mistral': 926, 'n_tokens_neox': 892, 'n_words': 176}