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

12 lines
418 B
JavaScript
Raw Normal View History

2015-08-20 00:23:42 +01:00
import { parse } from 'url';
2015-08-20 00:23:42 +01:00
export function match(url) {
var parsed = parse(url);
if (!parsed.host.match(/rd\.io$/) && !parsed.host.match(/rdio\.com$/)) {
return false;
}
2015-02-14 01:50:59 +00:00
var regular = parsed.path.match(/[\/]*artist[\/]*([^\/]*)[\/]*album[\/]*([^\/]*)[\/]*([track]*)?[\/]*([^\/]*)/);
var short = parsed.path.match(/[\/]*x[\/]*([^\/]*)/);
return (regular && !!regular[2]) || (short && !!short[1]);
};