line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::UnicodeNormalize; |
2
|
|
|
|
|
|
|
$Mojolicious::Plugin::UnicodeNormalize::VERSION = '1.20160509'; |
3
|
1
|
|
|
1
|
|
1171
|
use Mojolicious 6.41; |
|
1
|
|
|
|
|
218447
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
30
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
5
|
1
|
|
|
1
|
|
1153
|
use Unicode::Normalize (); |
|
1
|
|
|
|
|
151340
|
|
|
1
|
|
|
|
|
306
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub register { |
8
|
0
|
|
|
0
|
1
|
|
my ($self, $app, $conf) = @_; |
9
|
|
|
|
|
|
|
|
10
|
0
|
|
0
|
|
|
|
my $form = $conf->{form} // 'NFC'; |
11
|
0
|
|
|
|
|
|
my $normalizer = Unicode::Normalize->can( $form ); |
12
|
|
|
|
|
|
|
|
13
|
0
|
0
|
|
|
|
|
unless ($normalizer) { |
14
|
0
|
|
|
|
|
|
require Carp; |
15
|
0
|
|
|
|
|
|
Carp::croak( "Invalid normalization form '$form' requested" ); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $sub = sub { |
19
|
0
|
|
|
0
|
|
|
my $c = shift; |
20
|
0
|
|
|
|
|
|
my $params = $c->req->params; |
21
|
|
|
|
|
|
|
my $pairs = [ |
22
|
0
|
0
|
|
|
|
|
map { ref( $_ ) ? $_ : $normalizer->( $_ ) } @{ $params->pairs } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
]; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$params->pairs( $pairs ); |
26
|
0
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$app->hook( before_dispatch => $sub ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
__END__ |