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

Commit 932247a

Browse files
author
awalGarg
committed
wikipedia api changed, to slightly saner
so now no need to do `replace(' ', '_')`, we can get the link directly from the last inner array. I tested in the sandbox and it worked (IIRC)
1 parent c503d17 commit 932247a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

source/plugins/wiki.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ function command ( args, cb ) {
1616

1717
function finish ( resp ) {
1818
//the result will look like this:
19-
// [search_term, [title0, title1, title2, ...]]
20-
//we only asked for one result, so the 2nd array will have 1 item
19+
// [search_term, [title0, title1, title2, ...], [description0, description1...], [link0, link1...]]
20+
//we only asked for one result, so the inner arrays will have only 1 item each
2121
var title = resp[ 1 ][ 0 ],
2222
base = 'http://en.wikipedia.org/wiki/',
2323
found = true, res;
@@ -31,10 +31,7 @@ function command ( args, cb ) {
3131
].random();
3232
}
3333
else {
34-
//for some reason, wikipedia can't simply return a url
35-
title = encodeURIComponent( title.replace(/ /g, '_') );
36-
37-
res = base + title;
34+
res = resp[3][0]; // grab the link from the last inner array
3835
}
3936

4037
if ( cb && cb.call ) {

0 commit comments

Comments
 (0)