类型判断

@param {string}  type    url tel mobilePhone email account IdCard ip...参考regex 模块导出对象的属性
@param {string|number}  string
@example


```javascript
isType('email','user@163.com')   //=>true
```
@returns {boolean}
427292
function isType(type, string) {
    if (isString(string) || isNumber(string)) {
        if (_regex.regex[type] && type !== 'default') {
            string = String(string);
            return _regex.regex[type].test(string);
        } else {
            throw Error('unknown type ' + type);
        }
    } else {
        throw Error('type should be string or number');
    }
}
998614
function parseUrl(url) {
        if (Core.isBlank(url)) {
            return null;
        }
        var matches = url.match(httpRegex);
        if (matches === null) {
            return null;
        }
        //log.debug("matches: ", matches);
        var scheme = matches[1];
        var host = matches[3];
        var port = matches[4];
        var parts = null;
        if (!Core.isBlank(port)) {
            parts = url.split(port);
        }
        else {
            parts = url.split(host);
        }
        // make sure we use port as a number
        var portNum = Core.parseIntValue(port);
        var path = parts[1];
        if (path && _.startsWith(path, '/')) {
            path = path.slice(1, path.length);
        }
        //log.debug("parts: ", parts);
        return {
            scheme: scheme,
            host: host,
            port: portNum,
            path: path
        };
    }
1235999
function isIPv4(val) {
  // It will accept anything with three dots (.) and numeric digits
  const ipv4Regex = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;
  if (!ipv4Regex.test(val)) {
    return false;
  }
  // This part of code do checking for any invalid IP address like 256.256.256.256
  var parts = val.split('.').sort(function (a, b) {
    return a - b;
  });
  return parts[3] <= 255;
}
139146
function getType (str) {
  var ret = null
  var match = /[0-9]+,[0-9]+,.*/.test(str)
  if (!match) {
    return null
  }
  var a = str.split(',')
  if (a && a[1]) {
    ret = parseInt(a[1])
  } else {
    return null
  }
  if (isNaN(ret)) {
    return null
  }
  return ret
}
100824
def __isValidUrl(self, addr):
        
        regex = re.compile(
            r'^(?:http)s?://'  #: http:// or https://
            r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'  #: domain...
            r'localhost|'  #: localhost...
            r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'  #: ...or ip
            r'(?::\d+)?'  #: optional port
            r'(?:/?|[/?]\S+)$', re.IGNORECASE)
        if addr and isinstance(addr, string_types):
            if regex.match(addr):
                return True
        return False
802026
function _remove_type_callback(&$mime, $ext_type, $type_info)
    {
        // temporarily we'll put match to false
        $matched = false;
        list($ext, $type) = $ext_type;
        if ($type_info['wildcard']) {
            if (substr($type, 0, strpos($type, '/')) == $type_info['type']) {
                $matched = true;
            }
        } elseif ($type == $type_info['type']) {
            $matched = true;
        }
        if ($matched) {
            $this->remove_extension($ext);
            $type_info['last_match'] = true;
        } elseif ($type_info['last_match']) {
            // we do not need to continue if the previous type matched, but this type didn't.
            // because all types are sorted in alphabetical order, we can be sure there will be
            // no further successful matches.
            return false;
        }
        return true;
    }
478591
function _str(chunk, type) {
  var b, s = '';
  while(this._offset < chunk.length) {
    b = chunk[this._offset];
    if(b === CR && chunk[this._offset + 1] === LF) {
      this._offset += 2;
      return type === ERR ? new Error(s) : this.simple ? new String(s) : s;
    }
    s += String.fromCharCode(b);
    ++this._offset;
  }
}
737374
function typeOf (value) {
  var type = {
    hasValue: false,
    isArray: false,
    isPOJO: false,
    isNumber: false,
  };

  if (value !== undefined && value !== null) {
    type.hasValue = true;
    var typeName = typeof value;

    if (typeName === 'number') {
      type.isNumber = !isNaN(value);
    }
    else if (Array.isArray(value)) {
      type.isArray = true;
    }
    else {
      type.isPOJO =
        (typeName === 'object') &&
        !(value instanceof RegExp) &&
        !(value instanceof Date);
    }
  }

  return type;
}
818997
function typeClass (fullType) {
  fullType = util.removeLocation(fullType)
  if (fullType.lastIndexOf(']') === fullType.length - 1) {
    return 'array'
  }
  if (fullType.indexOf('mapping') === 0) {
    return 'mapping'
  }
  if (fullType.indexOf(' ') !== -1) {
    fullType = fullType.split(' ')[0]
  }
  var char = fullType.indexOf('bytes') === 0 ? 'X' : ''
  return fullType.replace(/[0-9]+/g, char)
}
880691
private boolean isTypeValid(char type) {
		return (type == MAPPED_ADDRESS || type == RESPONSE_ADDRESS
				|| type == SOURCE_ADDRESS || type == CHANGED_ADDRESS
				|| type == REFLECTED_FROM || type == XOR_MAPPED_ADDRESS
				|| type == ALTERNATE_SERVER || type == XOR_PEER_ADDRESS
				|| type == XOR_RELAYED_ADDRESS || type == DESTINATION_ADDRESS);
	}
682849
function isUrl (url) {
  if (!url) return false
  url = url.toString()
  return url.indexOf('http://') === 0 || url.indexOf('https://') === 0
}
1094617
int getType(InternetAddress address) {
        int type = NOT_FOUND;
        debug("Looking for: %s", address);
        debug("\tstarting at: %d", idx);
        int firstFoundIdx = findFirst(address);
        debug("\tfirstFoundIdx: %d", firstFoundIdx);
        if (firstFoundIdx != Integer.MAX_VALUE) {
            debug("\tfirstFoundIdx-substring: %s", recipients.substring(firstFoundIdx));
            type = getType(firstFoundIdx);
            debug("\t=> found type: %d", type);
            idx = firstFoundIdx + lengthOfTypePrefix(type) + address.toString().length()
                    + adaptLengthForOptionalPersonal(address) + 1;
        } else {
            debug("\t=> type not found");
        }
        return type;
    }
1155219
function(url, data, type) {
		assert(Login.app, "You must set Login.app = my-app-name-as-registered-with-you-again");
		data.app = Login.app;
		data.withCredentials = true; // let the server know this is a with-credentials call
		data.caller = ""+document.location; // provide some extra info
		// add in local cookie auth
		const cookies = Cookies.get();
		let cbase = cookieBase();
		for(let c in cookies) {			
			if (c.substr(0, cbase.length)===cbase) {
				let cv = Cookies.get(c);
				data[c] = cv;
			}
		}

		return $.ajax({
			dataType: "json", // not really needed but harmless
			url: url,
			data: data,
			type: type || 'GET',
			xhrFields: {withCredentials: true}
		});
	}
691224
def splittype(url):
    """"""
    global _typeprog
    if _typeprog is None:
        import re
        _typeprog = re.compile('^([^/:]+):')

    match = _typeprog.match(url)
    if match:
        scheme = match.group(1)
        return scheme.lower(), url[len(scheme) + 1:]
    return None, url
267024
def TypeUrlToMessage(type_url):
  """"""

  if not type_url.startswith(TYPE_URL_PREFIX):
    raise ValueError("Type URL has to start with a prefix %s: %s" %
                     (TYPE_URL_PREFIX, type_url))

  full_name = type_url[len(TYPE_URL_PREFIX):]
  try:
    return symbol_database.Default().GetSymbol(full_name)()
  except KeyError as e:
    raise ProtobufTypeNotFound(str(e))
1035289
function getContentType(url: string): string {
  url = trimUrlQuery(url);
  const dot = url.lastIndexOf(".");
  if (dot >= 0) {
    const name = url.substring(dot + 1);
    if (name in contentMap) {
      return contentMap[name];
    }
  }
  return "text/plain";
}
1211724
public final static boolean isUrlAddress(String str, ADictionary dic)
    {
        int prIndex = str.indexOf("://");
        if ( prIndex > -1 && ! StringUtil.isLatin(str, 0, prIndex) ) {
            return false;
        }
        
        int sIdx = prIndex > -1 ? prIndex + 3 : 0;
        int slIndex = str.indexOf('/', sIdx), sgIndex = str.indexOf('?', sIdx);
        int eIdx = slIndex > -1 ? slIndex : (sgIndex > -1 ? sgIndex : str.length());
        int lpIndex = -1;
        for ( int i = sIdx; i < eIdx; i++ ) {
            char chr = str.charAt(i);
            if ( chr == '.' ) {
                if ( lpIndex == -1 ) {
                    lpIndex = i;
                    continue;
                }
                
                if ( (i - lpIndex) == 1 || i == (eIdx - 1)) {
                    return false;
                }
                
                lpIndex = i;
            } else if ( ! StringUtil.isEnLetter(chr) 
                    && ! StringUtil.isEnNumeric(chr) ) {
                return false;
            }
        }
        
        if ( dic != null && ! dic.match(ILexicon.DOMAIN_SUFFIX, 
                str.substring(lpIndex+1, eIdx)) ) {
            return false;
        }
        
        //check the path part
        if ( slIndex > -1 ) {
            sIdx = slIndex;
            eIdx = sgIndex > -1 ? sgIndex : str.length();
            lpIndex = -1;
            for ( int i = sIdx; i < eIdx; i++ ) {
                char chr = str.charAt(i);
                if ( "./-_".indexOf(chr) > -1 ) {
                    if ( lpIndex == -1 ) {
                        lpIndex = i;
                        continue;
                    }
                    
                    if ( i - lpIndex == 1 || (chr == '.' && i == (eIdx - 1)) ) {
                        return false;
                    }
                    
                    lpIndex = i;
                } else if ( ! StringUtil.isEnLetter(chr) 
                        &&  ! StringUtil.isEnNumeric(chr) ) {
                    return false;
                }
            }
        }
        
        return true;
    }