| 1 |
// SPDX-License-Identifier: MPL-2.0 |
| 2 |
// (c) Hare authors <https://harelang.org> |
| 3 |
|
| 4 |
use strings; |
| 5 |
|
| 6 |
// Converts a human-readable domain name (e.g. "example.org") into a DNS-ready |
| 7 |
// name slice (e.g. ["example", "org"]). The slice returned must be freed by the |
| 8 |
// caller, but the members of the slice themselves are borrowed from the input. |
| 9 |
export fn parse_domain(in: str) ([]str | nomem) = strings::split(in, ".")?; |
| 10 |
|
| 11 |
// Converts a DNS name slice (e.g. ["example", "org"]) into a human-readable |
| 12 |
// domain name (e.g. "example.org"). The return value must be freed by the |
| 13 |
// caller. |
| 14 |
export fn unparse_domain(in: []str) (str | nomem) = strings::join(".", in...)?; |