diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-09-17 19:13:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-17 19:13:20 +0200 |
commit | 6453cb75670b6aefbfc712c7d05b1135bee6226c (patch) | |
tree | ab088478c374f7228f6891919dafcf01b66be037 /cli/ops/idna.rs | |
parent | a6f4559174c64066d45210b02f6a06aa2f67c2cd (diff) |
refactor: Move URL to op_crates/web (#7544)
Diffstat (limited to 'cli/ops/idna.rs')
-rw-r--r-- | cli/ops/idna.rs | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/cli/ops/idna.rs b/cli/ops/idna.rs deleted file mode 100644 index c81d9c314..000000000 --- a/cli/ops/idna.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. - -//! https://url.spec.whatwg.org/#idna - -use deno_core::error::uri_error; -use deno_core::error::AnyError; -use deno_core::ZeroCopyBuf; -use idna::domain_to_ascii; -use idna::domain_to_ascii_strict; -use serde::Deserialize; -use serde_json::Value; - -pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_sync(rt, "op_domain_to_ascii", op_domain_to_ascii); -} - -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -struct DomainToAscii { - domain: String, - be_strict: bool, -} - -fn op_domain_to_ascii( - _state: &mut deno_core::OpState, - args: Value, - _zero_copy: &mut [ZeroCopyBuf], -) -> Result<Value, AnyError> { - let args: DomainToAscii = serde_json::from_value(args)?; - if args.be_strict { - domain_to_ascii_strict(args.domain.as_str()) - } else { - domain_to_ascii(args.domain.as_str()) - } - .map_err(|err| { - let message = format!("Invalid IDNA encoded domain name: {:?}", err); - uri_error(message) - }) - .map(|domain| json!(domain)) -} |