1 | # Glob To Regular Expression
|
2 |
|
3 | [![Build Status](https://travis-ci.org/fitzgen/glob-to-regexp.png?branch=master)](https://travis-ci.org/fitzgen/glob-to-regexp)
|
4 |
|
5 | Turn a *-wildcard style glob (`"*.min.js"`) into a regular expression
|
6 | (`/^.*\.min\.js$/`)!
|
7 |
|
8 | ## Install
|
9 |
|
10 | npm install glob-to-regexp
|
11 |
|
12 | ## Usage
|
13 |
|
14 | var globToRegExp = require('blob-to-regexp');
|
15 | var re = globToRegExp("f*uck");
|
16 | re.test("firetruck"); // true
|
17 | re.test("fuck"); // true
|
18 |
|
19 | re = globToRegExp("*.min.js");
|
20 | re.test("http://example.com/jquery.min.js"); // true
|
21 | re.test("http://example.com/jquery.min.js.map"); // false
|
22 |
|
23 | re = globToRegExp("*/www/*.js");
|
24 | re.test("http://example.com/www/app.js"); // true
|
25 | re.test("http://example.com/www/lib/factory-proxy-model-observer.js"); // true
|
26 |
|
27 | ## License
|
28 |
|
29 | Copyright (c) 2013, Nick Fitzgerald
|
30 |
|
31 | All rights reserved.
|
32 |
|
33 | Redistribution and use in source and binary forms, with or without modification,
|
34 | are permitted provided that the following conditions are met:
|
35 |
|
36 | * Redistributions of source code must retain the above copyright notice, this
|
37 | list of conditions and the following disclaimer.
|
38 |
|
39 | * Redistributions in binary form must reproduce the above copyright notice, this
|
40 | list of conditions and the following disclaimer in the documentation and/or
|
41 | other materials provided with the distribution.
|
42 |
|
43 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
44 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
45 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
46 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
47 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
48 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
49 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
50 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
51 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
52 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|