line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::UnicodeNormalize; |
2
|
|
|
|
|
|
|
$Mojolicious::Plugin::UnicodeNormalize::VERSION = '1.20140306'; |
3
|
1
|
|
|
1
|
|
2213
|
use Mojolicious 4.55; |
|
1
|
|
|
|
|
725770
|
|
|
1
|
|
|
|
|
9
|
|
4
|
1
|
|
|
1
|
|
40
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
5
|
1
|
|
|
1
|
|
12056
|
use Unicode::Normalize (); |
|
1
|
|
|
|
|
2890
|
|
|
1
|
|
|
|
|
357
|
|
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
|
0
|
|
|
|
|
my $params = [ |
21
|
0
|
|
|
|
|
|
map { ref( $_ ) ? $_ : $normalizer->( $_ ) } |
22
|
0
|
|
|
|
|
|
@{ $c->req->params->params } |
23
|
|
|
|
|
|
|
]; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$c->req->params->params( $params ); |
26
|
0
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$app->hook( before_dispatch => $sub ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
__END__ |