Tag/xURL.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 44 CC 2 SCAR 10.3
CC
2
Cov
0%
replace
6.0
Tag
2.0
Class
2.0
CRAP 2.8
1 # $Id: xURL.pm 284 2006-12-01 07:51:49Z chronos $
2 package BBCode::Tag::xURL;
3 use base qw(BBCode::Tag);
4 use BBCode::Util qw(:parse :encode :text);
5 use strict;
6 use warnings;
7 our $VERSION = '0.34';
8  
9 sub Tag($):method {
10 return 'URL';
11 }
12  
13 sub Class($):method {
14 return qw(LINK INLINE);
15 }
16  
17 sub BodyPermitted($):method {
18 return 1;
19 }
20  
21 sub BodyTags($):method {
22 return qw(TEXT ENT);
23 }
24  
25 sub replace($):method {
26 my $this = shift;
27 my $text = $this->bodyHTML;
28 my $url = parseURL decodeHTML $text;
29  
30 if(defined $url) {
31 my $that = BBCode::Tag->new($this->parser, 'URL', [ undef, $url->as_string ]);
32 $that->pushBody(
33 BBCode::Tag->new($this->parser, 'TEXT', [ undef, textURL($url) ])
34 );
35 return $that;
36 } else {
37 return BBCode::Tag->new($this->parser, 'TEXT', [ undef, $text ]);
38 }
39 }
40  
41 1;