wishthis/node_modules/import-regex/index.js
2022-01-21 09:28:41 +01:00

17 lines
406 B
JavaScript

'use strict';
/**
* Regular expression for matching CSS @imports
*
* @param {Object} opts
* @api public
*/
module.exports = function (opts) {
opts = opts || {};
var regex = '(?:@import)(?:\\s)(?:url)?(?:(?:(?:\\()(["\'])?(?:[^"\')]+)\\1(?:\\))|(["\'])(?:.+)\\2)(?:[A-Z\\s])*)+(?:;)';
return opts.exact ? new RegExp('(?:^' + regex + '$)', 'i') :
new RegExp('(?:^|\\s)?' + regex, 'gi');
};