custom-media: use url.parse, not whatwg URL (node v6 compat)

This commit is contained in:
Calvin Montgomery 2017-08-06 21:59:14 -07:00
parent ea6e3f921f
commit c7f7dcfed3
1 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import { ValidationError } from './errors';
import { URL } from 'url';
import { parse as parseURL } from 'url';
import net from 'net';
const SOURCE_QUALITIES = new Set([
@ -105,7 +105,12 @@ function validateTextTracks(textTracks) {
function validateURL(urlstring) {
let url;
try {
url = new URL(urlstring);
url = parseURL(urlstring);
// legacy url.parse doesn't check this
if (url.protocol == null || url.host == null) {
throw new Error();
}
} catch (error) {
throw new ValidationError(`invalid URL "${urlstring}"`);
}