UI for Zipcoin Blue

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. /**
  3. * Check if we're required to add a port number.
  4. *
  5. * @see https://url.spec.whatwg.org/#default-port
  6. * @param {Number|String} port Port number we need to check
  7. * @param {String} protocol Protocol we need to check against.
  8. * @returns {Boolean} Is it a default port for the given protocol
  9. * @api private
  10. */
  11. module.exports = function required(port, protocol) {
  12. protocol = protocol.split(':')[0];
  13. port = +port;
  14. if (!port) return false;
  15. switch (protocol) {
  16. case 'http':
  17. case 'ws':
  18. return port !== 80;
  19. case 'https':
  20. case 'wss':
  21. return port !== 443;
  22. case 'ftp':
  23. return port !== 21;
  24. case 'gopher':
  25. return port !== 70;
  26. case 'file':
  27. return false;
  28. }
  29. return port !== 0;
  30. };