From 9e4626daa445f9a89e8778cf05b853f8b47bf165 Mon Sep 17 00:00:00 2001 From: Jonathan Cremin Date: Tue, 10 Apr 2018 23:55:24 +0100 Subject: [PATCH] Fix Spotify matching with their new urls --- lib/services/spotify/index.js | 3 ++- lib/services/spotify/url.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/services/spotify/index.js b/lib/services/spotify/index.js index 7ef2b94..c6cd127 100644 --- a/lib/services/spotify/index.js +++ b/lib/services/spotify/index.js @@ -38,6 +38,7 @@ function looseMatch(needle, haystack, type) { } export function* lookupId(id, type) { + console.log(id); const token = yield spotify.clientCredentialsGrant(); spotify.setAccessToken(token.body['access_token']); let data = yield spotify[`get${type.charAt(0).toUpperCase()}${type.slice(1)}s`]([id]); @@ -132,7 +133,7 @@ export function* search(data, original = {}) { } export function* parseUrl(url) { - const matches = parse(url).path.match(/\/(album|track)[/]+([^/]+)/); + const matches = parse(url).path.match(/\/(album|track)[/]+([A-Za-z0-9]+)/); if (matches && matches[2]) { return yield lookupId(matches[2], matches[1]); diff --git a/lib/services/spotify/url.js b/lib/services/spotify/url.js index 61cdb44..716624b 100644 --- a/lib/services/spotify/url.js +++ b/lib/services/spotify/url.js @@ -6,6 +6,6 @@ export default function match(url) { return false; } - const matches = parse(url).path.match(/\/(album|track)[/]+([^/]+)/); + const matches = parse(url).path.match(/\/(album|track)[/]+([A-Za-z0-9]+)/); return matches && !!matches[2]; }