Skip to content

Commit 1ee0912

Browse files
committed
add pattern using port to readme
1 parent f9c0385 commit 1ee0912

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Diff for: README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ bower install url-pattern
7676
null
7777
```
7878
``` javascript
79-
> var pattern = new UrlPattern('(http(s)\\://)(:subdomain.):domain.:tld(/*)')
79+
> var pattern = new UrlPattern('(http(s)\\://)(:subdomain.):domain.:tld(\\::port)(/*)')
8080

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

90+
> pattern.match('http://mail.google.com:80/mail');
91+
{subdomain: 'mail', domain: 'google', tld: 'com', port: '80', _: 'mail'}
92+
9093
> pattern.match('google');
9194
null
9295
```

Diff for: test/readme.coffee

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test 'api versioning', (t) ->
1515
t.end()
1616

1717
test 'domain', (t) ->
18-
pattern = new UrlPattern('(http(s)\\://)(:subdomain.):domain.:tld(/*)')
18+
pattern = new UrlPattern('(http(s)\\://)(:subdomain.):domain.:tld(\\::port)(/*)')
1919
t.deepEqual pattern.match('google.de'),
2020
domain: 'google'
2121
tld: 'de'
@@ -28,6 +28,12 @@ test 'domain', (t) ->
2828
domain: 'google'
2929
tld: 'com'
3030
_: 'mail'
31+
t.deepEqual pattern.match('http://mail.google.com:80/mail'),
32+
subdomain: 'mail'
33+
domain: 'google'
34+
tld: 'com'
35+
port: '80'
36+
_: 'mail'
3137
t.equal pattern.match('google'), null
3238

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

0 commit comments

Comments
 (0)