Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit 8ebd059

Browse files
author
Zirak
committed
Small fixes to @awalgarg's /wiki PR (#233).
1 parent 47169f3 commit 8ebd059

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

master.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6741,26 +6741,20 @@ function command ( args, cb ) {
67416741

67426742
function finish ( resp ) {
67436743
//the result will look like this:
6744-
// [search_term, [title0, title1, title2, ...]]
6745-
//we only asked for one result, so the 2nd array will have 1 item
6746-
var title = resp[ 1 ][ 0 ],
6744+
// [search_term, [title0], [description0], [link0]]
6745+
//we only asked for one result, so the inner arrays will have only 1 item each
6746+
var res = resp[ 3 ][ 0 ],
67476747
base = 'http://en.wikipedia.org/wiki/',
6748-
found = true, res;
6748+
found = true;
67496749

6750-
if ( !title ) {
6750+
if ( !res ) {
67516751
found = false;
67526752
res = [
67536753
'No result found',
67546754
'The Wikipedia contains no knowledge of such a thing',
67556755
'The Gods of Wikipedia did not bless us'
67566756
].random();
67576757
}
6758-
else {
6759-
//for some reason, wikipedia can't simply return a url
6760-
title = encodeURIComponent( title.replace(/ /g, '_') );
6761-
6762-
res = base + title;
6763-
}
67646758

67656759
if ( cb && cb.call ) {
67666760
cb( res );

0 commit comments

Comments
 (0)