2015-08-20 23:22:57 +01:00
|
|
|
import { parse } from 'url';
|
2014-12-11 19:53:12 +00:00
|
|
|
|
2017-07-20 14:31:07 +01:00
|
|
|
export default function match(url) {
|
|
|
|
const parsed = parse(url.replace(/\+/g, '%20'));
|
2014-12-11 19:53:12 +00:00
|
|
|
if (!parsed.host.match(/play\.google\.com$/)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-20 23:22:57 +01:00
|
|
|
const path = parsed.path;
|
|
|
|
const hash = parsed.hash;
|
2014-12-11 19:53:12 +00:00
|
|
|
|
|
|
|
if (hash) {
|
2017-07-20 14:31:07 +01:00
|
|
|
const parts = hash.split('/');
|
2015-08-20 23:22:57 +01:00
|
|
|
const id = parts[2];
|
|
|
|
const artist = parts[3];
|
2014-12-11 19:53:12 +00:00
|
|
|
|
|
|
|
if (id.length > 0) {
|
|
|
|
return true;
|
|
|
|
} else if (artist.length > 0) {
|
|
|
|
return true;
|
|
|
|
}
|
2017-07-20 14:31:07 +01:00
|
|
|
} else if (path) {
|
2015-08-20 23:22:57 +01:00
|
|
|
const matches = path.match(/\/music\/m\/([\w]+)/);
|
2014-12-11 19:53:12 +00:00
|
|
|
if (matches[1]) {
|
2017-07-20 14:31:07 +01:00
|
|
|
return true;
|
2014-12-11 19:53:12 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-20 14:31:07 +01:00
|
|
|
return false;
|
|
|
|
}
|