Skip to content

Commit

Permalink
Merge pull request #24 from oncletom/fix-24
Browse files Browse the repository at this point in the history
isValid() does the wrong job
  • Loading branch information
Oncle Tom committed Jan 8, 2013
2 parents c5518aa + 5b84a08 commit c4e459a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ var tld = require('tldjs');

### getDomain()

Returns the fully qualified domain from a host string.

```javascript
tld.getDomain('google.com'); // returns `google.com`
tld.getDomain('fr.google.com'); // returns `google.com`
Expand All @@ -39,11 +41,14 @@ tld.getDomain('fr.t.co'); // returns `t.co`

### isValid()

Checks if the host string is valid.
It does not check if the *tld* exists.

```javascript
tld.isValid('google.com'); // returns `true`
tld.isValid('t.co'); // returns `true`
tld.isValid('t.go'); // returns `false`

tld.isValid('.google.com'); // returns `false`
tld.isValid('my.fake.domain'); // returns `true`
tld.isValid('localhost'); // returns `false`
```

## Updating TLDs List
Expand Down
5 changes: 4 additions & 1 deletion lib/tld.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ tld.prototype.getDomain = function getDomain(host) {
};

/**
* Checking if a host is valid
* Checking if a host string is valid
* It's usually a preliminary check before trying to use getDomain or anything else
*
* Beware: it does not check if the TLD exists.
*
* @api
* @todo handle localhost, local etc.
Expand Down

0 comments on commit c4e459a

Please sign in to comment.