Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: Increase schema size to 15, allow point in URL schema #13

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ pub fn socket_path() -> PathBuf {
/// TODO: Could be stricter
/// - Must be at least 3 characters long
/// - Starts with an letter
/// - Has a colon within the first 10 characters and all preceding characters
/// must be letters, digits, `+` or `-`.
/// - Has a colon within the first 15 characters and all preceding characters
/// must be letters, digits, `+`, `-` or `.`.
pub fn is_uri_trustworthy(uri: &str) -> bool {
uri.chars().all(|c| c.is_ascii_graphic())
&& uri.len() >= 3
&& uri.bytes().next().unwrap().is_ascii_alphabetic()
&& uri
.bytes()
.take(10)
.take_while(|b| b.is_ascii_alphanumeric() || [b'+', b'-', b':'].contains(b))
.take(15)
.take_while(|b| b.is_ascii_alphanumeric() || [b'+', b'-', b':', b'.'].contains(b))
.any(|b| b == b':')
}

Expand Down