action() { const subdomainRegExp = /^https?:\/\/([a-z0-9]*).wordpress.com/; let subdomain = ''; if ( subdomainRegExp.test( this.props.redirectTo ) && config( 'hostname' ) !== 'wpcalypso.wordpress.com' && config( 'hostname' ) !== 'horizon.wordpress.com' ) { subdomain = this.props.redirectTo.match( subdomainRegExp )[ 1 ] + '.'; } return `https://${ subdomain }wordpress.com/wp-login.php`; }
filterTokens(params, "inline", (token) => { let childTokenTypes = ""; token.children.forEach((child) => { if (child.type !== "text" || child.content !== "") { childTokenTypes += tokenTypeMap[child.type] || "x"; } }); if (linkOrImageOnlyLineRe.test(childTokenTypes)) { linkOnlyLineNumbers.push(token.lineNumber); } });
function contains(name) { if (protocols.indexOf(name) != -1 || aliasProtocols[name] || PROXY_RE.test(name)) { return true; } name += ':'; return isWebsocketProtocol(name) || isWebProtocol(name) || isFileProxy(name) || name == 'tunnel:'; }
gqlOutputFieldResolvers() { return { [`${this.path}_is_set`]: item => { const val = item[this.path]; return bcryptHashRegex.test(val); }, }; }
/** * @description Search elements as getElementsByTagName with regex instead of string. * @param {Object} container - Element where execute research. * @param {RegExp} regex - Regex to search. * @returns {Array} Elements that match with regex. * @example * getElementsByTagRegex(document, /(cal:)?calendar-data/) */ function getElementsByTagRegex(container, regex) { return Array.from(container.getElementsByTagName('*')).filter((elem) => regex.test(elem.tagName)); }
function getCharset(str) { var charset; if (CHARSET_RE.test(str)) { charset = RegExp.$1; if (!iconv.encodingExists(charset)) { return; } } return charset; }
lines.split("\n").reduce((arr, line) => { if (this.includeRegex && this.includeRegex.test(line)) { const match = line.match(this.includeRegex); arr.push(typeof match[1] === "undefined" ? line : match[1]); } if (this.excludeRegex && !this.excludeRegex.test(line)) { arr.push(line); } return arr; }, [])
(names || []).forEach(name => { if (!labelRegexp.test(name)) { valid = false; } });
// from https://stackoverflow.com/questions/46155/how-can-you-validate-an-email-address-in-javascript const validEmailAddress = (email) => { // eslint-disable-next-line no-useless-escape, max-len const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ return re.test(String(email).toLowerCase()) }
/** * Checks if a ISO8601 formatted date contains a timezone component * @param pushTimeParam {string} * @returns {boolean} */ static pushTimeHasTimezoneComponent(pushTimeParam) { const offsetPattern = /(.+)([+-])\d\d:\d\d$/; return pushTimeParam.indexOf('Z') === pushTimeParam.length - 1 || // 2007-04-05T12:30Z offsetPattern.test(pushTimeParam); // 2007-04-05T12:30.000+02:00, 2007-04-05T12:30.000-02:00 }
function evalJson(str) { if (!JSON_RE.test(str)) { return; } with(ctx) { try { return eval('(' + str + ')'); } catch(e) {} } }
isBase64Value(object) { if (typeof object !== 'string') { return false; } return this.base64Pattern.test(object); }
// from https://stackoverflow.com/questions/46155/how-can-you-validate-an-email-address-in-javascript const validEmailAddress = (email) => { // eslint-disable-next-line no-useless-escape, max-len const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ return re.test(String(email).toLowerCase()) }
gqlOutputFieldResolvers() { return { [`${this.path}_is_set`]: item => { const val = item[this.path]; return bcryptHashRegex.test(val); }, }; }
/** * @description Search elements as getElementsByTagName with regex instead of string. * @param {Object} container - Element where execute research. * @param {RegExp} regex - Regex to search. * @returns {Array} Elements that match with regex. * @example * getElementsByTagRegex(document, /(cal:)?calendar-data/) */ function getElementsByTagRegex(container, regex) { return Array.from(container.getElementsByTagName('*')).filter((elem) => regex.test(elem.tagName)); }