* Performs encode on given content. * @protected * @param {Chain} content * @return {number[]|string|Uint8Array|Chain|Promise} Encoded content
(content)
| 64 | * @return {number[]|string|Uint8Array|Chain|Promise} Encoded content |
| 65 | */ |
| 66 | async performEncode (content) { |
| 67 | // Punycode is case insensitive, lowercase the content before continuing |
| 68 | content = content.toLowerCase() |
| 69 | |
| 70 | // Split domain into labels |
| 71 | const labels = content.split('.') |
| 72 | const encodedParts = new Array(labels.length) |
| 73 | |
| 74 | // Encode each part separately |
| 75 | for (let i = 0; i < labels.length; i++) { |
| 76 | // Check if the code points are all basic |
| 77 | if (this._nonBasicCodePointIndex(labels[i].getCodePoints()) === -1) { |
| 78 | // Return the part as is |
| 79 | encodedParts[i] = labels[i] |
| 80 | } else { |
| 81 | // Encode part using Bootstring and prepend IDNA prefix |
| 82 | const result = await this._bootstringEncoder.encode(labels[i]) |
| 83 | encodedParts[i] = prefix + result.getString() |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | // Stick domain labels back together |
| 88 | return Chain.join(encodedParts, '.') |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Performs decode on given content. |
nothing calls this directly
no test coverage detected