Skip to content

Commit

Permalink
Allow triple hyphen in IDNA hostnames, closes #466
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Dec 13, 2015
1 parent 5c0603c commit a2bf05d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#### HEAD

- Allow triple hyphens in IDNA hostnames
([#466](https://github.com/chriso/validator.js/issues/466))

#### 4.4.0

- Added `isMACAddress()` validator
Expand Down
1 change: 1 addition & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ describe('Validators', function () {
, 'http://foo--bar.com'
, 'http://høyfjellet.no'
, 'http://xn--j1aac5a4g.xn--j1amh'
, 'http://xn------eddceddeftq7bvv7c4ke4c.xn--p1ai'
, 'http://кулік.укр'
]
, invalid: [
Expand Down
6 changes: 4 additions & 2 deletions validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,10 @@
// disallow full-width chars
return false;
}
if (part[0] === '-' || part[part.length - 1] === '-' ||
part.indexOf('---') >= 0) {
if (part[0] === '-' || part[part.length - 1] === '-') {
return false;
}
if (part.indexOf('---') >= 0 && part.slice(0, 4) !== 'xn--') {
return false;
}
}
Expand Down

0 comments on commit a2bf05d

Please sign in to comment.