From 6d903a3f1615f6862bfc9b31c7ff5533c41df755 Mon Sep 17 00:00:00 2001 From: Jim Kang Date: Wed, 8 Apr 2015 14:26:06 -0400 Subject: [PATCH] Updated lookup to encode URI so that Arabic characters don't cause it to crash. --- src/store.js | 4 +++- test/test.js | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/store.js b/src/store.js index 54208aa..29ed6ea 100644 --- a/src/store.js +++ b/src/store.js @@ -29,7 +29,9 @@ ConceptNet.prototype.lookup = function(URI, params, callback) { var limit = params.limit || 50; var offset = params.offset || 0; - var path = "/data/" + this.version + String(URI) + "?limit=" + limit + "&offset=" + offset; + var path = "/data/" + this.version + String(encodeURIComponent(URI)) + + "?limit=" + limit + "&offset=" + offset; + if ( params.filter === "core" ) { path += "&filter=core"; } diff --git a/test/test.js b/test/test.js index fdc7b6b..9618392 100644 --- a/test/test.js +++ b/test/test.js @@ -103,6 +103,16 @@ describe('conceptNet', function tests() { ); }); + it('handles concepts in other languages', function otherLangTest(done) { + this.timeout(1000); + var cnet = new conceptNet(); + cnet.lookup("c/ar/سلام/",{ + filter: "core"}, function(err, result){ + assert(result.edges.length === 7); + done(); + } + ); + }); }); it('is possible to use search method to retrieve results', function test(done) {