mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
1f0360c073
Move all op related code of "ext/node" to "ext/node/ops" module. These files were unnecessarily scattered around the extension.
26 lines
641 B
Rust
26 lines
641 B
Rust
// 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()
|
|
}
|