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