blob: 8f7cfe34ab200d5dc2394d7eab84e05068ac6c8e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_core::error::AnyError;
use deno_core::op;
#[op]
pub fn op_node_idna_domain_to_ascii(
domain: String,
) -> Result<String, AnyError> {
Ok(idna::domain_to_ascii(&domain)?)
}
#[op]
pub fn op_node_idna_domain_to_unicode(domain: String) -> String {
idna::domain_to_unicode(&domain).0
}
#[op]
pub fn op_node_idna_punycode_decode(domain: String) -> String {
idna::punycode::decode_to_string(&domain).unwrap_or_default()
}
#[op]
pub fn op_node_idna_punycode_encode(domain: String) -> String {
idna::punycode::encode_str(&domain).unwrap_or_default()
}
|