forked from axios/axios
/
parseProtocol.js
24 lines (23 loc) · 914 Bytes
/
parseProtocol.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var assert = require('assert');
var utils = require('../../../lib/utils');
var parseProtocol = require('../../../lib/helpers/parseProtocol');
describe('helpers::parseProtocol', function () {
it('should parse protocol part if it exists', function () {
utils.forEach({
'http://username:password@example.com/': 'http',
'ftp:google.com': 'ftp',
'sms:+15105550101?body=hello%20there': 'sms',
'tel:0123456789' : 'tel',
'//google.com': '',
'google.com': '',
'admin://etc/default/grub' : 'admin',
'stratum+tcp://server:port': 'stratum+tcp',
'/api/resource:customVerb': '',
'https://stackoverflow.com/questions/': 'https',
'mailto:jsmith@example.com' : 'mailto',
'chrome-extension://1234/<pageName>.html' : 'chrome-extension'
}, (expectedProtocol, url) => {
assert.strictEqual(parseProtocol(url), expectedProtocol);
});
});
});