File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -412,6 +412,13 @@ sub content_is_json {
412
412
return $ct eq ' application/json' || $ct eq ' text/json' || $ct =~ / \+ json$ / ;
413
413
}
414
414
415
+ sub content_is_javascript {
416
+ my $ct = shift -> content_type;
417
+ # text/javascript is obsolete in RFC4329 but still used.
418
+ # No issue including it as well.
419
+ return $ct eq ' application/javascript' || $ct eq ' text/javascript' ;
420
+ }
421
+
415
422
sub referer {
416
423
my $self = shift ;
417
424
if (@_ && $_ [0] =~ / #/ ) {
@@ -749,6 +756,11 @@ content is XML. This method can't be used to set Content-Type.
749
756
Returns TRUE if the Content-Type header field indicate that the
750
757
content is JSON. This method can't be used to set Content-Type.
751
758
759
+ =item $h->content_is_javascript
760
+
761
+ Returns TRUE if the Content-Type header field indicate that the
762
+ content is JavaScript. This method can't be used to set Content-Type.
763
+
752
764
=item $h->content_encoding
753
765
754
766
The Content-Encoding header field is used as a modifier to the
Original file line number Diff line number Diff line change @@ -351,7 +351,7 @@ sub decoded_content
351
351
}
352
352
}
353
353
354
- if ($self -> content_is_text || (my $is_xml = $self -> content_is_xml) || $self -> content_is_json) {
354
+ if ($self -> content_is_text || (my $is_xml = $self -> content_is_xml) || $self -> content_is_json || $self -> content_is_javascript ) {
355
355
my $charset = lc (
356
356
$opt {charset } ||
357
357
$self -> content_type_charset ||
You can’t perform that action at this time.
0 commit comments