line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
1689677
|
use strict; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
114
|
|
2
|
5
|
|
|
5
|
|
17
|
use warnings; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
213
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Dancer2::Plugin::UnicodeNormalize; |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$Dancer2::Plugin::UnicodeNormalize::VERSION = '0.035'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
2141
|
use Dancer2::Plugin 0.150; |
|
5
|
|
|
|
|
169282
|
|
|
5
|
|
|
|
|
41
|
|
10
|
5
|
|
|
5
|
|
31615
|
use Unicode::Normalize; |
|
5
|
|
|
|
|
766361
|
|
|
5
|
|
|
|
|
2065
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
on_plugin_import { |
13
|
|
|
|
|
|
|
my $dsl = shift; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# pre Plugin2 we need to get settings here |
16
|
|
|
|
|
|
|
my $settings = plugin_setting; |
17
|
|
|
|
|
|
|
$dsl->app->add_hook( |
18
|
|
|
|
|
|
|
Dancer2::Core::Hook->new( |
19
|
|
|
|
|
|
|
name => 'before', |
20
|
|
|
|
|
|
|
code => sub { |
21
|
|
|
|
|
|
|
# perhaps better ways to check for Plugin2 but this works |
22
|
|
|
|
|
|
|
if ( $dsl->can('execute_plugin_hook')) { |
23
|
|
|
|
|
|
|
# Plugin2 - fetch fresh config on each run |
24
|
|
|
|
|
|
|
$settings = plugin_setting; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
for (@{$settings->{'exclude'}}) { return if $dsl->app->request->path =~ /$_/ } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $form = $settings->{'form'} || 'NFC'; |
29
|
|
|
|
|
|
|
my $normalizer = Unicode::Normalize->can($form); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
unless ($normalizer) { |
32
|
|
|
|
|
|
|
require Carp; |
33
|
|
|
|
|
|
|
Carp::croak( "Invalid normalization form '$form' requested" ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
for (qw/query body route/) { |
37
|
|
|
|
|
|
|
my $p = $dsl->app->request->params($_); |
38
|
|
|
|
|
|
|
next unless $p; |
39
|
|
|
|
|
|
|
%{$p} = map { $_ => $normalizer->($p->{$_}) } grep { $p->{$_} } keys %{$p}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
$dsl->app->request->_build_params; |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
), |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
register_plugin for_versions => [2]; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |