Skip to content

Commit fe27944

Browse files
committed
Implement DuckDuckGo-like ! (or \\) syntax for IFL
Instead of having to pass lucky=1 as a GET parameter you can now enter a search term beginning with "!" or "\" to have MetaCPAN return the first result to you. E.g. searching for "!Plack" or "\Plack" will redirect you to /module/Plack. This is an alternative to pressing Shift+Enter on the site to go to the first result, but the real value is being able to use e.g. DuckDuckGo to search for "!cpan !Plack" to go to the first MetaCPAN result. See-Also: metacpan#269
1 parent bcfec8c commit fe27944

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/MetaCPAN/Web/Controller/Search.pm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ sub index : Path {
2323

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

0 commit comments

Comments
 (0)