Skip to content

Commit

Permalink
Merge pull request #13 from Entytaiment25/domain-input-fix
Browse files Browse the repository at this point in the history
fixing issue #12 and cleaning up code
  • Loading branch information
Entytaiment25 authored Feb 28, 2024
2 parents db52065 + 43074e0 commit ad380ca
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

println!("{}", message);

let destination = if destination.starts_with("https://") {
if destination.ends_with('/') {
destination.strip_prefix("https://").unwrap().strip_suffix('/').unwrap()
} else {
destination.strip_prefix("https://").unwrap()
let destination = match
destination.strip_prefix("https://").or_else(|| destination.strip_prefix("http://"))
{
Some(without_protocol) => {
without_protocol
.split_once('/')
.map(|(before, _)| before)
.unwrap_or(without_protocol)
}
} else if destination.starts_with("http://") {
if destination.ends_with('/') {
destination.strip_prefix("http://").unwrap().strip_suffix('/').unwrap()
} else {
destination.strip_prefix("http://").unwrap()
}
} else {
destination
None => destination,
};

let with_port = format!("{}:{}", destination, port);
Expand Down

0 comments on commit ad380ca

Please sign in to comment.