From df59c3e192d8211f0610b73ae0269b7ca5363ed2 Mon Sep 17 00:00:00 2001 From: Manraj Singh Date: Thu, 7 Sep 2017 02:13:46 +0530 Subject: [PATCH] Dota 2: Fixes #3296 Skeleton King Trigger not working (#3341) * Dota 2: Fixes #3296 Skeleton King Trigger not working * Issue #3296: Changes split and join to replace --- share/spice/dota2/dota2.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/share/spice/dota2/dota2.js b/share/spice/dota2/dota2.js index 7bcbc788d1..37ebb48758 100644 --- a/share/spice/dota2/dota2.js +++ b/share/spice/dota2/dota2.js @@ -3,6 +3,7 @@ function getItemFromData(itemdata, itemName) { var item; + if (itemdata[itemName]) { item = itemdata[itemName]; } else { @@ -83,6 +84,7 @@ function getHeroFromData(herodata, heroName) { var hero; + if (herodata[heroName]) { hero = herodata[heroName]; hero.heroKey = heroName; @@ -179,10 +181,12 @@ } var searchTarget = DDG.get_query().toLowerCase().replace(/dota\s?2/, "").trim(); + var keyTarget = searchTarget.replace(' ', '_'); var returnData; - var item = getItemFromData(api_result.itemdata, searchTarget); + var item = getItemFromData(api_result.itemdata, keyTarget); var sourceUrl; var template; + if (typeof item !== 'undefined') { returnData = createItemReturnObject(item, api_result); sourceUrl = 'https://www.dota2.com/items/'; @@ -193,7 +197,7 @@ } }; } else { - var hero = getHeroFromData(api_result.herodata, searchTarget); + var hero = getHeroFromData(api_result.herodata, keyTarget); if (!hero) { return Spice.failed('dota2'); } returnData = createHeroReturnObject(hero, api_result);