mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat(unstable): --allow-net subdomain wildcards (#29327)
This commit is contained in:
parent
cb23193f74
commit
ab9673dcc1
15 changed files with 377 additions and 54 deletions
|
@ -5,6 +5,7 @@ use std::str::FromStr;
|
|||
|
||||
use deno_core::url::Url;
|
||||
use deno_runtime::deno_permissions::NetDescriptor;
|
||||
use deno_runtime::deno_permissions::UnstableSubdomainWildcards;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct ParsePortError(String);
|
||||
|
@ -32,7 +33,11 @@ pub fn validator(host_and_port: &str) -> Result<String, String> {
|
|||
if Url::parse(&format!("internal://{host_and_port}")).is_ok()
|
||||
|| host_and_port.parse::<IpAddr>().is_ok()
|
||||
|| host_and_port.parse::<BarePort>().is_ok()
|
||||
|| NetDescriptor::parse(host_and_port).is_ok()
|
||||
|| NetDescriptor::parse_for_list(
|
||||
host_and_port,
|
||||
UnstableSubdomainWildcards::Enabled,
|
||||
)
|
||||
.is_ok()
|
||||
{
|
||||
Ok(host_and_port.to_string())
|
||||
} else {
|
||||
|
@ -52,7 +57,11 @@ pub fn parse(paths: Vec<String>) -> clap::error::Result<Vec<String>> {
|
|||
out.push(format!("{}:{}", host, port.0));
|
||||
}
|
||||
} else {
|
||||
NetDescriptor::parse(&host_and_port).map_err(|e| {
|
||||
NetDescriptor::parse_for_list(
|
||||
&host_and_port,
|
||||
UnstableSubdomainWildcards::Enabled,
|
||||
)
|
||||
.map_err(|e| {
|
||||
clap::Error::raw(clap::error::ErrorKind::InvalidValue, e.to_string())
|
||||
})?;
|
||||
out.push(host_and_port)
|
||||
|
@ -120,6 +129,7 @@ mod tests {
|
|||
let entries = svec![
|
||||
"deno.land",
|
||||
"deno.land:80",
|
||||
"*.deno.land",
|
||||
"[::]",
|
||||
"[::1]",
|
||||
"127.0.0.1",
|
||||
|
@ -141,6 +151,7 @@ mod tests {
|
|||
let expected = svec![
|
||||
"deno.land",
|
||||
"deno.land:80",
|
||||
"*.deno.land",
|
||||
"[::]",
|
||||
"[::1]",
|
||||
"127.0.0.1",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue