/**
 * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

const escapeStringRegexp = require( 'escape-string-regexp' );

/**
 * Converts the specified `pattern` to an instance of RegExp.
 *
 * @param {String} pattern
 * @return {RegExp}
 */
module.exports = function globToRegexp( pattern ) {
	return new RegExp(
		escapeStringRegexp( pattern ).replace( /\\\*/g, '[\\s\\S]*' ).replace( /\//g, '[\\\\/]' )
	);
};
