mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-03 05:55:03 +01:00
25 lines
766 B
TypeScript
25 lines
766 B
TypeScript
import { parseHostname } from '../src/parseHostname';
|
|
|
|
const fixtures = [
|
|
['localHOst', 'localhost'],
|
|
['localhost.cz:3', 'localhost.cz'],
|
|
['wss://btc.trezor.io/foo', 'btc.trezor.io'],
|
|
['127.0.0.1:9050/?a=b', '127.0.0.1'],
|
|
['http://suite.trezor.io/', 'suite.trezor.io'],
|
|
['electrum.exAMple.com:50001:t', 'electrum.example.com'],
|
|
['electrum.example.onion:50001:t?abcd', 'electrum.example.onion'],
|
|
['a35sf65dFH67awd.onion:999:s', 'a35sf65dfh67awd.onion'],
|
|
[''],
|
|
['ws://'],
|
|
['http://a.b://c.d'],
|
|
['invalid url'],
|
|
] as const;
|
|
|
|
describe('parseHostname', () => {
|
|
it('parseHostname', () => {
|
|
fixtures.forEach(([url, hostname]) => {
|
|
expect(parseHostname(url)).toEqual(hostname);
|
|
});
|
|
});
|
|
});
|