Update load.ts

This commit is contained in:
Acid Chicken (硫酸鶏) 2019-02-04 02:09:41 +09:00 committed by GitHub
parent 353fc18f19
commit 67792fcb5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -59,6 +59,7 @@ function validateUrl(url: string) {
const result = tryCreateUrl(url); const result = tryCreateUrl(url);
if (result.pathname.trim('/').length) throw `url="${url}" is not a valid URL, has a pathname.`; if (result.pathname.trim('/').length) throw `url="${url}" is not a valid URL, has a pathname.`;
if (!url.includes(result.host)) throw `url="${url}" is not a valid URL, has an invalid hostname.`; if (!url.includes(result.host)) throw `url="${url}" is not a valid URL, has an invalid hostname.`;
if (!/^https?:$/.test(result.protocol)) throw `url="${url}" is not a valid URL, has an invalid protocol.`;
return result; return result;
} }