From 3b59787e3fbd3726e0024a76a7f5ab53c6479b61 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sun, 11 Jan 2015 11:46:34 +0100 Subject: [PATCH] added support for more abbreviations --- lib/match.js | 20 +++++++++++++------- package.json | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/match.js b/lib/match.js index 914724b..d1ef256 100644 --- a/lib/match.js +++ b/lib/match.js @@ -55,6 +55,18 @@ var checkDistance = function(s1, s2) { return d[s1.length][s2.length] <= k; }; +/** + * Supported artist name abbreviations. + */ + +var abbreviations = { + ccr: 'creedence clearwater revival', + elo: 'electric light orchestra', + omd: 'orchestral manoeuvres in the dark', + rhcp: 'red hot chili peppers', + jsbx: 'the jon spencer blues explosion' +}; + /** * Expose a function to check if the user answer is acceptable. */ @@ -132,13 +144,7 @@ module.exports = function(pattern, guess, enableartistrules) { } } } - if (guess === 'ccr' && artist === 'creedence clearwater revival') { - return true; - } - if (guess === 'elo' && artist === 'electric light orchestra') { - return true; - } - if (guess === 'omd' && artist === 'orchestral manoeuvres in the dark') { + if (guess in abbreviations && artist === abbreviations[guess]) { return true; } } diff --git a/package.json b/package.json index 957ba60..7724646 100644 --- a/package.json +++ b/package.json @@ -35,5 +35,5 @@ "start": "node app.js" }, "subdomain": "binb", - "version": "0.5.4-1" + "version": "0.5.5" } -- 2.54.0