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