diff --git a/.travis.yml b/.travis.yml index a0a6dd9..52ba159 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ +sudo: false language: node_js node_js: - - 0.11 - - 0.10 + - 'stable' + - '0.12' + - '0.10' diff --git a/index.js b/index.js index a38ac6b..2ad515f 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ -'use strict'; +'use strict' -module.exports = function() { - return /url\(.*?\)/ig; +module.exports = function () { + return /url\((.*?)\)/ig } diff --git a/license b/license new file mode 100644 index 0000000..38250b0 --- /dev/null +++ b/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) John Otander (johnotander.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/package.json b/package.json index fccb0d5..ad7d6a0 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "css-url-regex", - "version": "0.0.1", + "version": "1.1.0", "description": "Regular expression for matching CSS urls.", "main": "index.js", - "directories": { - "test": "test" - }, + "files": [ + "index.js" + ], "scripts": { - "test": "mocha test" + "test": "ava" }, "repository": { "type": "git", @@ -26,6 +26,6 @@ }, "homepage": "https://github.com/johnotander/css-url-regex", "devDependencies": { - "mocha": "^2.0.1" + "ava": "^0.2.0" } } diff --git a/README.md b/readme.md similarity index 55% rename from README.md rename to readme.md index e4a8528..b1603a7 100644 --- a/README.md +++ b/readme.md @@ -1,10 +1,6 @@ -# CSS Url Regex +# css-url-regex [![Build Status](https://travis-ci.org/cssstats/css-url-regex.svg?branch=master)](https://travis-ci.org/johnotander/css-url-regex) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) -[![Build Status](https://travis-ci.org/johnotander/css-url-regex.svg?branch=master)](https://travis-ci.org/johnotander/css-url-regex) - -A regular expression for matching CSS urls (`url(foo.css)`). - -In the near future this will be likely moved to . +A regular expression for matching CSS urls, `url(foo.css)`. ## Installation @@ -15,7 +11,7 @@ npm i --save css-url-regex ## Usage ```javascript -var cssUrl = require('css-url-regex'); +var cssUrl = require('css-url-regex') cssUrl().test('url(bar.css)') // => true cssUrl().test('kljhsdf') // => false diff --git a/test/test.js b/test.js similarity index 52% rename from test/test.js rename to test.js index 38a0de3..3c05f44 100644 --- a/test/test.js +++ b/test.js @@ -1,6 +1,35 @@ -var assert = require('assert'); -var cssUrl = require('..'); +import test from 'ava' +import cssUrlRegex from './' +const matches = [ + 'url(foo.css)', + "url('foo.css')", + 'url(foo/bar.css)', + 'url(http://google.com/foo/bar)' +] + +const nonMatches = [ + 'foo', + '(foo.css)', + 'url (foo.css)' +] + +test('matches urls', t => { + t.plan(matches.length) + + matches.forEach((match) => { + t.ok(cssUrlRegex().test(match)) + }) +}) + +test('does not match non existent urls', t => { + t.plan(nonMatches.length) + + nonMatches.forEach((nonMatch) => { + t.notOk(cssUrlRegex().test(nonMatch)) + }) +}) +/* describe('css-url-regex', function() { it('should find a css url with no quotes', function() { @@ -21,3 +50,4 @@ describe('css-url-regex', function() { ["url(foo.css)", "url(bar.css)"]); }); }); +*/