Skip to content

Instantly share code, notes, and snippets.

@oliwer
Last active March 26, 2016 00:51
Show Gist options
  • Save oliwer/d1216099b998cff5c228 to your computer and use it in GitHub Desktop.
Save oliwer/d1216099b998cff5c228 to your computer and use it in GitHub Desktop.
WWW::Shorten::SCK
package WWW::Shorten::SCK;
#
# URL shortening provider for http://sck.pm
#
use strict;
use warnings;
sub new { bless {} }
sub shorterlink_start {
my ($self, $link) = @_;
{ GET => "http://sck.pm/?a=1&url=$link" }
}
sub shorterlink_result {
my ($self, $content) = @_;
if ($content =~ /^(http\S+)/) {
return $1;
}
die $content;
}
sub longerlink_start {
my ($self, $link) = @_;
$link = "http://sck.pm/$link" unless
$link =~ /^http/;
{ GET => $link }
}
sub longerlink_result { die $_[1] }
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment