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

14 lines
339 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(/youtu\.be$/)) {
return true;
} else if (parsed.host.match(/youtube\.com$/)) {
2015-08-20 23:22:57 +01:00
const query = querystring.parse(parsed.query);
return !!query.v;
}
return false;
};