Skip to content

Commit

Permalink
fixed small quality detection bug in Mojolicious::Types
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jun 1, 2013
1 parent 03a1f9c commit 25c46e4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,6 +1,7 @@

4.11 2013-06-02
- Added parse_header function to Mojo::Util.
- Fixed small quality detection bug in Mojolicious::Types.
- Fixed a few small boundary and charset detection bugs in Mojo::Content.

4.10 2013-06-01
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Util.pm
Expand Up @@ -520,7 +520,7 @@ Monkey patch functions into package.
=head2 parse_header
my $parsed = parse_header 'foo="bar baz"; test=123, yada';
my $tree = parse_header 'foo="bar baz"; test=123, yada';
Parse HTTP header value.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Types.pm
Expand Up @@ -37,7 +37,7 @@ sub detect {

# Extract and prioritize MIME types
my %types;
/^\s*([^,; ]+)(?:\s*\;\s*q=(\d+(?:\.\d+)?))?\s*$/i
/^\s*([^,; ]+)(?:\s*\;\s*q\s*=\s*(\d+(?:\.\d+)?))?\s*$/i
and $types{lc $1} = $2 // 1
for split /,/, $accept // '';
my @detected = sort { $types{$b} <=> $types{$a} } sort keys %types;
Expand Down
2 changes: 2 additions & 0 deletions t/mojolicious/types.t
Expand Up @@ -71,6 +71,8 @@ is_deeply $t->detect('text/plain', 1), ['txt'], 'right formats';
is_deeply $t->detect('text/plain,text/html', 1), ['htm', 'html', 'txt'],
'right formats';
is_deeply $t->detect('TEXT/HTML; q=0.8 ', 1), ['htm', 'html'], 'right formats';
is_deeply $t->detect('TEXT/HTML ; q = 0.8 ', 1), ['htm', 'html'],
'right formats';
is_deeply $t->detect('TEXT/HTML;Q=0.8,text/plain;Q=0.9', 1),
['txt', 'htm', 'html'], 'right formats';
is_deeply $t->detect(' TEXT/HTML , text/plain;Q=0.9', 1),
Expand Down

0 comments on commit 25c46e4

Please sign in to comment.