2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00

Enhanced protocol parsing implementation to fix #4633; (#4639)

Added unit tests;

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Dmitriy Mozgovoy
2022-04-27 12:30:50 +03:00
committed by GitHub
parent 76432c18be
commit b9e9fb4fa0
3 changed files with 32 additions and 2 deletions
+24
View File
@@ -0,0 +1,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);
});
});
});