UNPKG

2.1 kBMarkdownView Raw
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
5Turn 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
29Copyright (c) 2013, Nick Fitzgerald
30
31All rights reserved.
32
33Redistribution and use in source and binary forms, with or without modification,
34are 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
43THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
44ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
45WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
46DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
47ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
48(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
50ANY 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
52SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.