Utils.ts 523 B

123456789101112131415161718192021222324
  1. export class Utils {
  2. /**
  3. * @type {string}
  4. */
  5. public static readonly hexadecimalPrefix: string = '0x';
  6. /**
  7. * @param {string} url
  8. * @returns {string}
  9. */
  10. public static extractDomainFrom (url: string): string {
  11. let domain: string;
  12. if (url.indexOf('://') > -1 || url.indexOf('//') === 0) {
  13. domain = url.split('/')[2];
  14. } else {
  15. domain = url.split('/')[0];
  16. }
  17. domain = domain.split(':')[0];
  18. return domain;
  19. }
  20. }