| 1 | # tr46
|
|---|
| 2 |
|
|---|
| 3 | An JavaScript implementation of [Unicode Technical Standard #46: Unicode IDNA Compatibility Processing](https://unicode.org/reports/tr46/).
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 | ## Installation
|
|---|
| 7 |
|
|---|
| 8 | [Node.js](http://nodejs.org) ≥ 8 is required. To install, type this at the command line:
|
|---|
| 9 | ```shell
|
|---|
| 10 | npm install tr46
|
|---|
| 11 | # or
|
|---|
| 12 | yarn add tr46
|
|---|
| 13 | ```
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | ## API
|
|---|
| 17 |
|
|---|
| 18 | ### `toASCII(domainName[, options])`
|
|---|
| 19 |
|
|---|
| 20 | Converts a string of Unicode symbols to a case-folded Punycode string of ASCII symbols.
|
|---|
| 21 |
|
|---|
| 22 | Available options:
|
|---|
| 23 | * [`checkBidi`](#checkBidi)
|
|---|
| 24 | * [`checkHyphens`](#checkHyphens)
|
|---|
| 25 | * [`checkJoiners`](#checkJoiners)
|
|---|
| 26 | * [`processingOption`](#processingOption)
|
|---|
| 27 | * [`useSTD3ASCIIRules`](#useSTD3ASCIIRules)
|
|---|
| 28 | * [`verifyDNSLength`](#verifyDNSLength)
|
|---|
| 29 |
|
|---|
| 30 | ### `toUnicode(domainName[, options])`
|
|---|
| 31 |
|
|---|
| 32 | Converts a case-folded Punycode string of ASCII symbols to a string of Unicode symbols.
|
|---|
| 33 |
|
|---|
| 34 | Available options:
|
|---|
| 35 | * [`checkBidi`](#checkBidi)
|
|---|
| 36 | * [`checkHyphens`](#checkHyphens)
|
|---|
| 37 | * [`checkJoiners`](#checkJoiners)
|
|---|
| 38 | * [`processingOption`](#processingOption)
|
|---|
| 39 | * [`useSTD3ASCIIRules`](#useSTD3ASCIIRules)
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 | ## Options
|
|---|
| 43 |
|
|---|
| 44 | ### `checkBidi`
|
|---|
| 45 | Type: `Boolean`
|
|---|
| 46 | Default value: `false`
|
|---|
| 47 | When set to `true`, any bi-directional text within the input will be checked for validation.
|
|---|
| 48 |
|
|---|
| 49 | ### `checkHyphens`
|
|---|
| 50 | Type: `Boolean`
|
|---|
| 51 | Default value: `false`
|
|---|
| 52 | When set to `true`, the positions of any hyphen characters within the input will be checked for validation.
|
|---|
| 53 |
|
|---|
| 54 | ### `checkJoiners`
|
|---|
| 55 | Type: `Boolean`
|
|---|
| 56 | Default value: `false`
|
|---|
| 57 | When set to `true`, any word joiner characters within the input will be checked for validation.
|
|---|
| 58 |
|
|---|
| 59 | ### `processingOption`
|
|---|
| 60 | Type: `String`
|
|---|
| 61 | Default value: `"nontransitional"`
|
|---|
| 62 | When set to `"transitional"`, symbols within the input will be validated according to the older IDNA2003 protocol. When set to `"nontransitional"`, the current IDNA2008 protocol will be used.
|
|---|
| 63 |
|
|---|
| 64 | ### `useSTD3ASCIIRules`
|
|---|
| 65 | Type: `Boolean`
|
|---|
| 66 | Default value: `false`
|
|---|
| 67 | When set to `true`, input will be validated according to [STD3 Rules](http://unicode.org/reports/tr46/#STD3_Rules).
|
|---|
| 68 |
|
|---|
| 69 | ### `verifyDNSLength`
|
|---|
| 70 | Type: `Boolean`
|
|---|
| 71 | Default value: `false`
|
|---|
| 72 | When set to `true`, the length of each DNS label within the input will be checked for validation.
|
|---|