Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #3161 from duckduckgo/mintsoft/conversions-whitesp…
Browse files Browse the repository at this point in the history
…acing

Conversions: Hack tweaks for #3160
  • Loading branch information
zekiel committed May 30, 2016
2 parents 871be32 + 5bb7b0f commit 51fb944
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/DDG/Goodie/Conversions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ handle query_lc => sub {
$_ =~ s/ degree[s]? (celsius|fahrenheit|rankine)/ $1/;

# hack - convert "oz" to "fl oz" if "ml" contained in query
s/\b(oz|ounces)/fl oz/ if(/(ml|cup[s]?)/ && not /fl oz/);
s/(oz|ounces)/fl oz/ if(/(ml|cup[s]?)/ && not /fl oz/);

# guard the query from spurious matches
return unless $_ =~ /$guard/;
Expand Down
12 changes: 12 additions & 0 deletions t/Conversions.t
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,18 @@ ddg_goodie_test(
physical_quantity => 'volume'
})
),
'100oz to ml' => test_zci(
'100 us fluid ounces = 2,957.353 millilitres',
structured_answer => make_answer({
markup_input => '100',
raw_input => '100',
from_unit => 'us fluid ounces',
styled_output => '2,957.353',
raw_answer => '2957.353',
to_unit => 'millilitres',
physical_quantity => 'volume'
})
),
'100 ml to oz' => test_zci(
'100 millilitres = 3.381 us fluid ounces',
structured_answer => make_answer({
Expand Down

0 comments on commit 51fb944

Please sign in to comment.