Skip to content

Commit a2bf05d

Browse files
committed
Allow triple hyphen in IDNA hostnames, closes #466
1 parent 5c0603c commit a2bf05d

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#### HEAD
2+
3+
- Allow triple hyphens in IDNA hostnames
4+
([#466](https://github.com/chriso/validator.js/issues/466))
5+
16
#### 4.4.0
27

38
- Added `isMACAddress()` validator

test/validators.js

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ describe('Validators', function () {
183183
, 'http://foo--bar.com'
184184
, 'http://høyfjellet.no'
185185
, 'http://xn--j1aac5a4g.xn--j1amh'
186+
, 'http://xn------eddceddeftq7bvv7c4ke4c.xn--p1ai'
186187
, 'http://кулік.укр'
187188
]
188189
, invalid: [

validator.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,10 @@
399399
// disallow full-width chars
400400
return false;
401401
}
402-
if (part[0] === '-' || part[part.length - 1] === '-' ||
403-
part.indexOf('---') >= 0) {
402+
if (part[0] === '-' || part[part.length - 1] === '-') {
403+
return false;
404+
}
405+
if (part.indexOf('---') >= 0 && part.slice(0, 4) !== 'xn--') {
404406
return false;
405407
}
406408
}

0 commit comments

Comments
 (0)