combine.fm/lib/services/itunes/url.js

16 lines
383 B
JavaScript
Raw Normal View History

2015-08-20 23:22:57 +01:00
import { parse } from 'url';
import querystring from 'querystring';
2015-08-20 23:22:57 +01:00
export function* match(url, type) {
const parsed = parse(url);
if (!parsed.host.match(/itunes.apple\.com$/)) {
return false;
}
2015-08-20 23:22:57 +01:00
const matches = parsed.path.match(/[\/]?([\/]?[a-z]{2}?)?[\/]+album[\/]+([^\/]+)[\/]+([^\?]+)/);
const query = querystring.parse(parsed.query);
return !!matches[3];
};