Major refactor of service libs, more tests

This commit is contained in:
Jonathan Cremin 2014-12-11 19:53:12 +00:00
parent cda69ea472
commit ce3ff0442c
19 changed files with 288 additions and 118 deletions

View file

@ -0,0 +1,30 @@
"use strict";
var parse = require('url').parse;
module.exports.match = function(url) {
var parsed = parse(url.replace(/\+/g, "%20"));
if (!parsed.host.match(/play\.google\.com$/)) {
return false;
}
var path = parsed.path;
var hash = parsed.hash;
if (hash) {
var parts = hash.split("/");
var id = parts[2];
var artist = parts[3];
if (id.length > 0) {
return true;
} else if (artist.length > 0) {
return true;
}
} else if(path) {
var matches = path.match(/\/music\/m\/([\w]+)/);
if (matches[1]) {
return true
}
}
return false
};