| 1 | package WWW::Shorten::VGd; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use base qw( WWW::Shorten::generic Exporter ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | our @EXPORT = qw( makeashorterlink makealongerlink ); | |||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | use Carp (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use HTML::Entities qw(decode_entities); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 2 | our $VERSION = '0.005'; | |||||||||
| 13 | 2 | $VERSION = eval $VERSION; | |||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub makeashorterlink { | ||||||||
|
Subroutine
makeashorterlink: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 16 | 0 | ▶ | my $url = shift or Carp::croak('No URL passed to makeashorterlink'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 0 | my $ua = __PACKAGE__->ua(); | |||||||||
| 18 | 0 | my $response = $ua->post('https://v.gd/create.php', { | |||||||||
| 19 | url => $url, | ||||||||||
| 20 | format => 'simple', | ||||||||||
| 21 | }); | ||||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | return unless $response->is_success; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | my $shorturl = $response->decoded_content(); | |||||||||
| 25 | 0 | ▶ | return undef unless $shorturl; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | ▶ | return undef if $shorturl =~ m/^\s*Error/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 0 | return $shorturl; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | sub makealongerlink { | ||||||||
|
Subroutine
makealongerlink: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 31 | 0 | ▶ | my $url = shift or Carp::croak('No v.gd key/URL passed to makealongerlink'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 0 | my $ua = __PACKAGE__->ua(); | |||||||||
| 33 | |||||||||||
| 34 | 0 | $url =~ s{\Qhttps?://v.gd/\E}{}i; | |||||||||
| 35 | 0 | my $res = $ua->post('https://v.gd/forward.php', { | |||||||||
| 36 | shorturl => $url, | ||||||||||
| 37 | format => 'simple', | ||||||||||
| 38 | }); | ||||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | return undef unless $res->is_success; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | my $longurl = $res->decoded_content; | |||||||||
| 42 | 0 | ▶ | return undef unless $longurl; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | ▶ | return undef if $longurl =~ m/^\s*Error/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 0 | return decode_entities($longurl); | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 2 | 1; | |||||||||
| 48 | |||||||||||
| 49 | __END__ | ||||||||||