| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Safer::alphanum_kebab_nodashend_lc; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
354091
|
use 5.010001; |
|
|
1
|
|
|
|
|
3
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
27
|
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
255
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
8
|
|
|
|
|
|
|
our $DATE = '2025-06-14'; # DATE |
|
9
|
|
|
|
|
|
|
our $DIST = 'Text-Safer'; # DIST |
|
10
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our %META = ( |
|
13
|
|
|
|
|
|
|
summary => 'Like alphanum_kebab, but additionally lower case & remove dash at the beginning & end of text, e.g. "Foo Bar, Co., Ltd." -> "foo-bar-co-ltd"', |
|
14
|
|
|
|
|
|
|
args => { |
|
15
|
|
|
|
|
|
|
}, |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub encode_safer { |
|
19
|
0
|
|
|
0
|
1
|
|
my ($text, $args) = @_; |
|
20
|
0
|
|
0
|
|
|
|
$args //= {}; |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
$text =~ s/[^A-Za-z0-9_-]+/-/g; |
|
23
|
0
|
|
|
|
|
|
$text =~ s/-\z//; $text =~ s/\A-//; |
|
|
0
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
$text = "-" if !length($text); |
|
25
|
0
|
|
|
|
|
|
lc $text; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
|
29
|
|
|
|
|
|
|
# ABSTRACT: Like alphanum_kebab, but additionally lower case & remove dash at the beginning & end of text, e.g. "Foo Bar, Co., Ltd." -> "foo-bar-co-ltd" |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__END__ |