25개 이상의 토픽을 선택하실 수 없습니다.
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- 'use strict';
- import tld from 'tldjs';
-
- function _ipIsValid(ipAddress) {
- return Boolean(/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipAddress));
- }
-
- function getDomainName(urlStr) {
- const domain = tld.getDomain(urlStr);
- const subDomain = tld.getSubdomain(urlStr);
- const ip = `${subDomain}.${domain}`;
- if (_ipIsValid(ip)) {
- return ip;
- }
- return domain;
- }
-
- export {getDomainName, _ipIsValid};
|