You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
597 B

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = throwIfNonHttpProtocol;
/**
* Check if a string is an http/https url
*/
function throwIfNonHttpProtocol(url) {
const _url = new URL(url);
const urlProtocol = _url.protocol;
const expectedProtocol = {
[urlProtocol]: false,
'http:': true,
'https:': true
};
const isFromExpectedProtocol = expectedProtocol[urlProtocol];
if (!isFromExpectedProtocol) {
throw new Error('invalid url, missing http/https protocol');
}
}
//# sourceMappingURL=throwIfNonHttpProtocol.js.map