Robots.js
function parsePattern(pattern) {
	var regexSpecialChars = /[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g;
	// Treat consecutive wildcards as one (#12)
	var wildCardPattern = /\*+/g;
	var endOfLinePattern = /\\\$$/;

	pattern = normaliseEncoding(pattern)

	if (pattern.indexOf('*') < 0 && pattern.indexOf('$') < 0) {
		return pattern;
	}

	pattern = pattern
		.replace(regexSpecialChars, '\\$&')
		.replace(wildCardPattern, '(?:.*)')
		.replace(endOfLinePattern, '$');

	return new RegExp(pattern);
}
function parsePattern(pattern) {
	var regexSpecialChars = /[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g;
	// Treat consecutive wildcards as one (#12)
	var wildCardPattern = /\*+/g;
	var endOfLinePattern = /\\\$$/;

	pattern = normaliseEncoding(pattern)

	if (pattern.indexOf('*') < 0 && pattern.indexOf('$') < 0) {
		return pattern;
	}

	pattern = pattern
		.replace(regexSpecialChars, '\\$&')
		.replace(wildCardPattern, '(?:.*)')
		.replace(endOfLinePattern, '$');

	return new RegExp(pattern);
}
function parsePattern ( pattern ) { var regexSpecialChars = / [\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|] / g ; // Treat consecutive wildcards as one (#12) var wildCardPattern = / \*+ / g ; var endOfLinePattern = / \\\$$ / ; pattern = normaliseEncoding ( pattern ) if ( pattern . indexOf ( '*' ) < 0 && pattern . indexOf ( '$' ) < 0 ) { return pattern ; } pattern = pattern . replace ( regexSpecialChars , '\\$&' ) . replace ( wildCardPattern , '(?:.*)' ) . replace ( endOfLinePattern , '$' ) ; return new RegExp ( pattern ) ; }
Converts the pattern into a regexp if it is a wildcard
pattern.

Returns a string if the pattern isn't a wildcard pattern

@param  {string} pattern
@return {string|RegExp}
@private
Converts the pattern into a regexp if it is a wildcard pattern .