line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::UnicodeNormalize; |
2
|
|
|
|
|
|
|
$Mojolicious::Plugin::UnicodeNormalize::VERSION = '1.20170726'; |
3
|
1
|
|
|
1
|
|
1707
|
use Mojolicious 7.0; |
|
1
|
|
|
|
|
534071
|
|
|
1
|
|
|
|
|
12
|
|
4
|
1
|
|
|
1
|
|
54
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
7
|
|
5
|
1
|
|
|
1
|
|
1293
|
use Unicode::Normalize (); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
307
|
|
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 $params = $_[0]->req->params; |
20
|
|
|
|
|
|
|
my $pairs = [ |
21
|
0
|
0
|
|
|
|
|
map { ref( $_ ) ? $_ : $normalizer->( $_ ) } @{ $params->pairs } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
]; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
$params->pairs( $pairs ); |
25
|
0
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$app->hook( before_dispatch => $sub ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
__END__ |