/
githubmirror
/
axios
Обзор
Документация
Войти
/
githubmirror
/
axios
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v1.x
tests/unit/parseProtocol.test.js
32 строки
1 KB
DeepView Autofix
fix(parseProtocol): fix regex to require colon in protocol separator (#10729)
25 апр 2026, 19:27
Не верифицирован
25 апр 2026, 19:27
f2dc449
Код
Авторство
О чём код?
import { describe, it } from 'vitest'; import assert from 'assert'; import utils from '../../lib/utils.js'; import parseProtocol from '../../lib/helpers/parseProtocol.js'; describe('helpers::parseProtocol', () => { it('should parse protocol part if it exists', () => { 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); } ); }); it('should not match URLs without a colon separator', () => { assert.strictEqual(parseProtocol('http//example.com'), ''); }); });