@@ -876,22 +876,48 @@ for (const [name, value] of params) {
876876 // xyz baz
877877```
878878
879- ### require('url').domainToAscii (domain)
879+ ### require('url').domainToASCII (domain)
880880
881881* ` domain ` {String}
882882* Returns: {String}
883883
884- Returns the [ Punycode] [ ] ASCII serialization of the ` domain ` .
884+ Returns the [ Punycode] [ ] ASCII serialization of the ` domain ` . If ` domain ` is an
885+ invalid domain, the empty string is returned.
885886
886- * Note* : The ` require('url').domainToAscii() ` method is introduced as part of
887+ It performs the inverse operation to [ ` require('url').domainToUnicode() ` ] [ ] .
888+
889+ ``` js
890+ const url = require (' url' );
891+ console .log (url .domainToASCII (' español.com' ));
892+ // Prints xn--espaol-zwa.com
893+ console .log (url .domainToASCII (' 中文.com' ));
894+ // Prints xn--fiq228c.com
895+ console .log (url .domainToASCII (' xn--iñvalid.com' ));
896+ // Prints an empty string
897+ ```
898+
899+ * Note* : The ` require('url').domainToASCII() ` method is introduced as part of
887900the new ` URL ` implementation but is not part of the WHATWG URL standard.
888901
889902### require('url').domainToUnicode(domain)
890903
891904* ` domain ` {String}
892905* Returns: {String}
893906
894- Returns the Unicode serialization of the ` domain ` .
907+ Returns the Unicode serialization of the ` domain ` . If ` domain ` is an invalid
908+ domain, the empty string is returned.
909+
910+ It performs the inverse operation to [ ` require('url').domainToASCII() ` ] [ ] .
911+
912+ ``` js
913+ const url = require (' url' );
914+ console .log (url .domainToUnicode (' xn--espaol-zwa.com' ));
915+ // Prints español.com
916+ console .log (url .domainToUnicode (' xn--fiq228c.com' ));
917+ // Prints 中文.com
918+ console .log (url .domainToUnicode (' xn--iñvalid.com' ));
919+ // Prints an empty string
920+ ```
895921
896922* Note* : The ` require('url').domainToUnicode() ` API is introduced as part of the
897923the new ` URL ` implementation but is not part of the WHATWG URL standard.
@@ -956,6 +982,8 @@ console.log(myURL.origin);
956982[ `URLSearchParams` ] : #url_class_urlsearchparams
957983[ `urlSearchParams.entries()` ] : #url_urlsearchparams_entries
958984[ `urlSearchParams@@iterator()` ] : #url_urlsearchparams_iterator
985+ [ `require('url').domainToASCII()` ] : #url_require_url_domaintoascii_domain
986+ [ `require('url').domainToUnicode()` ] : #url_require_url_domaintounicode_domain
959987[ stable sorting algorithm ] : https://en.wikipedia.org/wiki/Sorting_algorithm#Stability
960988[ `JSON.stringify()` ] : https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
961989[ `url.toJSON()` ] : #url_url_tojson
0 commit comments