From db877d302cb7429627f1ed4dc9a02bc3ecc3c550 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Tue, 9 Aug 2016 13:11:43 +0200 Subject: [PATCH] Fix issue with local tracks in dups detection --- src/server.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/server.js b/src/server.js index 5445f21..ecf3197 100644 --- a/src/server.js +++ b/src/server.js @@ -200,8 +200,6 @@ app.get('/pl/:uId/:plId', function (req, res) { } i++; } - array.forEach(function (other, otherIndex) { - }); }); res.send({ 'data': dups @@ -211,7 +209,7 @@ app.get('/pl/:uId/:plId', function (req, res) { /** * @typedef {Object} track - * @property {number} id + * @property {number|null} id * @property {string} name * @property {[artist]} artists */ @@ -231,14 +229,14 @@ app.get('/pl/:uId/:plId', function (req, res) { function areDups(track1, track2) { var name1 = track1.name.toLowerCase(); var name2 = track2.name.toLowerCase(); - if (track1.id == track2.id) { + if (track1.id != null && track2.id != null && track1.id == track2.id) { return true; } else if (haveCommonArtist(track1, track2)) { if (name1 == name2) { return true; } - else if (name1.includes(name2) || name2.includes(name1)) { + else if (name1.startsWith(name2) || name2.startsWith(name1)) { return true; } }