You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

23 line
965 B

  1. import test from 'ava';
  2. import {getDomainName, _ipIsValid} from '../extension/url-parser';
  3. test(t => {
  4. t.is('lesspass.com', getDomainName('https://lesspass.com/#!/'));
  5. t.is('lesspass.com', getDomainName('https://lesspass.com/api/'));
  6. t.is('lesspass.com', getDomainName('https://api.lesspass.com/'));
  7. t.is('192.168.1.1', getDomainName('https://192.168.1.1:10443/webapp/'));
  8. });
  9. test('ip validator', t => {
  10. t.true(_ipIsValid('192.168.23.215'));
  11. t.true(_ipIsValid('127.0.0.1'));
  12. t.false(_ipIsValid('210.110'), 'must have 4 octets');
  13. t.false(_ipIsValid('255'), 'must have 4 octets');
  14. t.false(_ipIsValid('y.y.y.y'), 'only digits are allowed');
  15. t.false(_ipIsValid('255.0.0.y'), 'only digits are allowed');
  16. t.false(_ipIsValid('666.10.10.20'), 'octet number must be between [0-255]');
  17. t.false(_ipIsValid('4444.11.11.11'), 'octet number must be between [0-255]');
  18. t.false(_ipIsValid('33.3333.33.3'), 'octet number must be between [0-255]');
  19. });