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
lib/services/itunes

View file

@ -0,0 +1,15 @@
"use strict";
var parse = require('url').parse;
module.exports.match = function(url, type) {
var parsed = parse(url);
if (!parsed.host.match(/itunes.apple\.com$/)) {
return false;
}
var matches = parsed.path.match(/[\/]?([\/]?[a-z]{2}?)?[\/]+album[\/]+([^\/]+)[\/]+([^\?]+)/);
var query = querystring.parse(parsed.query);
return !!matches[3];
};