1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = throwIfNonHttpProtocol;
|
7 |
|
8 |
|
9 |
|
10 | function throwIfNonHttpProtocol(url) {
|
11 | const _url = new URL(url);
|
12 | const urlProtocol = _url.protocol;
|
13 | const expectedProtocol = {
|
14 | [urlProtocol]: false,
|
15 | 'http:': true,
|
16 | 'https:': true
|
17 | };
|
18 | const isFromExpectedProtocol = expectedProtocol[urlProtocol];
|
19 | if (!isFromExpectedProtocol) {
|
20 | throw new Error('invalid url, missing http/https protocol');
|
21 | }
|
22 | }
|
23 |
|
24 |
|
\ | No newline at end of file |