Skip to content

Commit

Permalink
add pattern using port to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
snd committed Dec 19, 2015
1 parent f9c0385 commit 1ee0912
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bower install url-pattern
null
```
``` javascript
> var pattern = new UrlPattern('(http(s)\\://)(:subdomain.):domain.:tld(/*)')
> var pattern = new UrlPattern('(http(s)\\://)(:subdomain.):domain.:tld(\\::port)(/*)')

> pattern.match('google.de');
{domain: 'google', tld: 'de'}
Expand All @@ -87,6 +87,9 @@ null
> pattern.match('http://mail.google.com/mail');
{subdomain: 'mail', domain: 'google', tld: 'com', _: 'mail'}

> pattern.match('http://mail.google.com:80/mail');
{subdomain: 'mail', domain: 'google', tld: 'com', port: '80', _: 'mail'}

> pattern.match('google');
null
```
Expand Down
8 changes: 7 additions & 1 deletion test/readme.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test 'api versioning', (t) ->
t.end()

test 'domain', (t) ->
pattern = new UrlPattern('(http(s)\\://)(:subdomain.):domain.:tld(/*)')
pattern = new UrlPattern('(http(s)\\://)(:subdomain.):domain.:tld(\\::port)(/*)')
t.deepEqual pattern.match('google.de'),
domain: 'google'
tld: 'de'
Expand All @@ -28,6 +28,12 @@ test 'domain', (t) ->
domain: 'google'
tld: 'com'
_: 'mail'
t.deepEqual pattern.match('http://mail.google.com:80/mail'),
subdomain: 'mail'
domain: 'google'
tld: 'com'
port: '80'
_: 'mail'
t.equal pattern.match('google'), null

t.deepEqual pattern.match('www.google.com'),
Expand Down

0 comments on commit 1ee0912

Please sign in to comment.