Skip to content
This repository was archived by the owner on Mar 28, 2018. It is now read-only.

Commit a7fe658

Browse files
committed
Initial commit
0 parents  commit a7fe658

File tree

5 files changed

+90
-0
lines changed

5 files changed

+90
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# CSS Url Regex
2+
3+
[![Build Status](https://travis-ci.org/johnotander/css-url-regex.svg?branch=master)](https://travis-ci.org/johnotander/css-url-regex)
4+
5+
A regular expression for matching CSS urls (`url(foo.css)`).
6+
7+
In the near future this will be likely moved to <https://github.com/regexps>.
8+
9+
## Installation
10+
11+
```
12+
npm i --save css-url-regex
13+
```
14+
15+
## Usage
16+
17+
```javascript
18+
var cssUrl = require('css-url-regex');
19+
20+
cssUrl().test('url(bar.css)') // => true
21+
cssUrl().test('kljhsdf') // => false
22+
```
23+
24+
## License
25+
26+
MIT
27+
28+
## Contributing
29+
30+
1. Fork it
31+
2. Create your feature branch (`git checkout -b my-new-feature`)
32+
3. Commit your changes (`git commit -am 'Add some feature'`)
33+
4. Push to the branch (`git push origin my-new-feature`)
34+
5. Create new Pull Request
35+
36+
Crafted with <3 by [John Otander](http://johnotander.com).

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
module.exports = function() {
4+
return /url\(.*?\)/ig;
5+
}

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "css-url-regex",
3+
"version": "0.0.1",
4+
"description": "Regular expression for matching CSS urls.",
5+
"main": "index.js",
6+
"directories": {
7+
"test": "test"
8+
},
9+
"scripts": {
10+
"test": "mocha test"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/johnotander/css-url-regex.git"
15+
},
16+
"keywords": [
17+
"css",
18+
"css-url",
19+
"regex",
20+
"regexp"
21+
],
22+
"author": "John Otander <johnotander@gmail.com> (http://johnotander.com/)",
23+
"license": "MIT",
24+
"bugs": {
25+
"url": "https://github.com/johnotander/css-url-regex/issues"
26+
},
27+
"homepage": "https://github.com/johnotander/css-url-regex",
28+
"devDependencies": {
29+
"mocha": "^2.0.1"
30+
}
31+
}

test/test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var assert = require('assert');
2+
var cssUrl = require('..');
3+
4+
describe('css-url-regex', function() {
5+
6+
it('should find a css url with no quotes', function() {
7+
assert.equal(cssUrl().test('url(foo.css)'), true);
8+
});
9+
10+
it('should find a css url with quotes', function() {
11+
assert.equal(cssUrl().test("url('foo.css')"), true);
12+
});
13+
14+
it('should not find a css url if it is not there', function() {
15+
assert.equal(cssUrl().test("('foo.css')"), false);
16+
});
17+
});

0 commit comments

Comments
 (0)