Skip to content

Commit a53d982

Browse files
authored
Merge pull request #2 from jdesrosiers/types
Add types
2 parents 2563cf7 + e9cc699 commit a53d982

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

index.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import punycode = require('punycode/');
2+
3+
/**
4+
* Validate a hostname. Returns true or throws a detailed error.
5+
*
6+
* @throws {SyntaxError}
7+
*/
8+
declare function isIdnHostname(hostname: string): true;
9+
10+
/**
11+
* Returns the ACE hostname or throws a detailed error (it also validates the input)
12+
*
13+
* @throws {SyntaxError}
14+
*/
15+
declare function idnHostname(hostname: string): string;
16+
17+
/**
18+
* Returns the uts46 mapped label (not hostname) or throws an error if the label
19+
* has dissallowed or unassigned chars.
20+
*
21+
* @throws {SyntaxError}
22+
*/
23+
declare function uts46map(label: string): string;
24+
25+
declare const IdnHostname: {
26+
isIdnHostname: typeof isIdnHostname;
27+
idnHostname: typeof idnHostname;
28+
uts46map: typeof uts46map;
29+
punycode: typeof punycode;
30+
};
31+
32+
export = IdnHostname;

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@
2626
},
2727
"dependencies": {
2828
"punycode": "^2.3.1"
29+
},
30+
"devDependencies": {
31+
"@types/punycode": "^2.1.4"
2932
}
3033
}

0 commit comments

Comments
 (0)