Skip to content

Commit

Permalink
Merge pull request #270 from CPAN-API/avar/ddg-bang-syntax
Browse files Browse the repository at this point in the history
Implement DuckDuckGo-like ! (or \\) syntax for IFL
  • Loading branch information
oalders committed Jun 16, 2013
2 parents cd7c3c6 + fe27944 commit 2f7c576
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/MetaCPAN/Web/Controller/Search.pm
Expand Up @@ -25,7 +25,10 @@ sub index : Path {

my $model = $c->model('API::Module');
my $from = ( $req->page - 1 ) * 20;
if ( $req->parameters->{lucky} ) {
if ( $req->parameters->{lucky} or
# DuckDuckGo-like syntax for bangs that redirect to the first
# result.
$query =~ s[^ (?: \\ | ! ) ][]x) {
my $module = $model->first($query)->recv;
$c->detach('/not_found') unless ($module);
$c->res->redirect("/module/$module");
Expand Down

0 comments on commit 2f7c576

Please sign in to comment.