import-regex
Advanced tools
Comparing version 1.0.1 to 1.1.0
10
index.js
@@ -6,7 +6,13 @@ 'use strict'; | ||
* | ||
* @param {Object} opts | ||
* @api public | ||
*/ | ||
module.exports = function () { | ||
return /@import\s+(?:url\s?\((?:[^)]+)\))|@import\s+(\'|")(?:.*)\1/gi; | ||
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'); | ||
}; |
{ | ||
"name": "import-regex", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Regular expression for matching CSS @imports", | ||
@@ -27,4 +27,4 @@ "license": "MIT", | ||
"devDependencies": { | ||
"ava": "0.0.4" | ||
"ava": "^0.0.4" | ||
} | ||
} |
@@ -16,10 +16,13 @@ # import-regex [![Build Status](https://travis-ci.org/kevva/import-regex.svg?branch=master)](https://travis-ci.org/kevva/import-regex) | ||
importRegex().test('@import url(\'foo.css\');'); | ||
importRegex().test('@import url(\'foo.css\'); foo bar'); | ||
//=> true | ||
importRegex().exec('This is a CSS import @import url(\'foo.css\');')[0].trim(); | ||
//=> @import url('foo.css') | ||
importRegex({ exact: true }).test('@import url(\'foo.css\'); foo bar'); | ||
//=> false | ||
'Multiple @import url(\'foo.css\'); @import url(\'bar.css\'); CSS imports'.match(importRegex()); | ||
//=> ['@import url('foo.css')', '@import url('bar.css')'] | ||
importRegex({ exact: true }).test('@import url(\'foo.css\');'); | ||
//=> true | ||
'foo @import url(\'foo.css\'); bar @import url(\'bar.css\');'.match(importRegex()); | ||
//=> ['@import url('foo.css');', '@import url('bar.css');'] | ||
``` | ||
@@ -26,0 +29,0 @@ |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2741
4
13
32
0