You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.1 KiB

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