Skip to content

Commit 725a2b2

Browse files
committed
README: adapt to API changes and freshen up
1 parent 57f4ce3 commit 725a2b2

File tree

1 file changed

+19
-36
lines changed

1 file changed

+19
-36
lines changed

README.md

+19-36
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,38 @@
11
# url-pattern
22

3-
[![Build Status](https://travis-ci.org/snd/url-pattern.png)](https://travis-ci.org/snd/url-pattern)
3+
[![NPM Package](https://img.shields.io/npm/v/url-pattern.svg?style=flat)](https://www.npmjs.org/package/url-pattern)
4+
[![Build Status](https://travis-ci.org/snd/url-pattern.svg?branch=master)](https://travis-ci.org/snd/url-pattern/branches)
5+
[![Dependencies](https://david-dm.org/snd/url-pattern.svg)](https://david-dm.org/snd/url-pattern)
46

5-
url-pattern is easy pattern matching and segment extraction for
6-
urls, domains, filepaths and any string composed of segments joined
7-
by a separator character
7+
> url-pattern is easy pattern matching and segment extraction for
8+
> urls, domains, filepaths and any string composed of segments joined
9+
> by a separator character
810
911
[check out **passage** if you are looking for simple composable routing that builds on top of url-pattern](https://github.com/snd/passage)
1012

11-
- [install](#install)
12-
- [require](#require)
13-
- [match urls or filepaths](#match-urls-or-filepaths)
14-
- [match domains](#match-domains)
15-
- [license](#license-mit)
16-
17-
### install
18-
1913
```
2014
npm install url-pattern
2115
```
2216

23-
**or**
24-
25-
put this line in the dependencies section of your `package.json`:
26-
27-
```
28-
"url-pattern": "0.6.0"
29-
```
30-
31-
then run:
32-
33-
```
34-
npm install
35-
```
36-
37-
### require
17+
require with commonjs:
3818

3919
```javascript
40-
var urlPattern = require('url-pattern');
20+
var Pattern = require('url-pattern');
4121
```
4222

23+
[lib/url-pattern.js](lib/url-pattern.js) can be used in the browser.
24+
it supports AMD as well.
25+
4326
### match urls or filepaths
4427

4528
##### make pattern from string
4629

4730
```javascript
48-
var pattern = urlPattern.newPattern('/users/:id');
31+
var pattern = new Pattern('/users/:id');
4932
```
5033

5134
the default separator is `/`. you can pass a custom separator
52-
as the second argument to `newPattern`.
35+
as the second argument.
5336

5437
##### match pattern against url
5538

@@ -63,7 +46,7 @@ pattern.match('/projects/5'); // => null
6346
##### make pattern from regex
6447

6548
```javascript
66-
var regexPattern = urlPattern.newPattern(/\/test\/(.*)/);
49+
var regexPattern = new Pattern(/\/test\/(.*)/);
6750
```
6851

6952
##### match regex pattern against url
@@ -78,7 +61,7 @@ regexPattern.match('/users/test'); // => null
7861
##### make wildcard pattern from string
7962

8063
```javascript
81-
var wildcardPattern = urlPattern.newPattern('*/users/:id/*');
64+
var wildcardPattern = new Pattern('*/users/:id/*');
8265
```
8366

8467
##### match wildcard pattern against url
@@ -93,7 +76,7 @@ wildcardPattern.match('/api/v1/users/10/followers/20');
9376
##### make optional pattern from string
9477

9578
```javascript
96-
var optionalPattern = urlPattern.newPattern('(/)users(/:foo)/bar(/*)');
79+
var optionalPattern = new Pattern('(/)users(/:foo)/bar(/*)');
9780
```
9881

9982
##### match optional pattern against url
@@ -116,7 +99,7 @@ optionalPattern.match('/users/biff/bar/beep/boop');
11699
##### make pattern from string
117100

118101
```javascript
119-
var pattern = urlPattern.newPattern(':sub.google.com', '.');
102+
var pattern = new Pattern(':sub.google.com', '.');
120103
```
121104

122105
the default separator is `/`. you can pass a custom separator
@@ -149,7 +132,7 @@ regexPattern.match('google.com'); // => null
149132
##### make wildcard pattern from string
150133

151134
```javascript
152-
var wildcardPattern = urlPattern.newPattern('*.:sub.google.*');
135+
var wildcardPattern = new Pattern('*.:sub.google.*');
153136
```
154137

155138
##### match wildcard pattern against url
@@ -161,4 +144,4 @@ wildcardPattern.match('subsub.www.google.com');
161144
// => {sub: 'www', _: ['subsub', 'com']}
162145
```
163146

164-
### license: MIT
147+
## [license: MIT](LICENSE)

0 commit comments

Comments
 (0)