Require user-supplied URLs to be http protocol

This commit is contained in:
Max Goodhart
2020-06-20 23:02:47 -07:00
parent 23e195ba03
commit 1217eeb92f
3 changed files with 11 additions and 0 deletions

6
src/util.js Normal file
View File

@@ -0,0 +1,6 @@
export function ensureValidURL(urlStr) {
const url = new URL(urlStr)
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
throw new Error(`rejecting attempt to load non-http URL '${urlStr}'`)
}
}