diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-04-24 12:22:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-24 12:22:21 +0200 |
commit | 1f0360c07382dbd86066d1aa8aa4bae34aff18c5 (patch) | |
tree | cc82d00aea829f0b3d3949f40df9696b099ee662 /ext/node/ops/idna.rs | |
parent | 28e2c7204fe02304a8fc3339d7758eec0f64f723 (diff) |
refactor(ext/node): reorganize ops (#18799)
Move all op related code of "ext/node" to "ext/node/ops" module.
These files were unnecessarily scattered around the extension.
Diffstat (limited to 'ext/node/ops/idna.rs')
-rw-r--r-- | ext/node/ops/idna.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ext/node/ops/idna.rs b/ext/node/ops/idna.rs new file mode 100644 index 000000000..8f7cfe34a --- /dev/null +++ b/ext/node/ops/idna.rs @@ -0,0 +1,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() +} |