Skip to content

Commit

Permalink
Handle wildcard pattern separately
Browse files Browse the repository at this point in the history
  • Loading branch information
jochasinga committed Nov 2, 2022
1 parent 11b9846 commit 2a6748f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions transports/websocket/src/framed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ pub(crate) fn get_address_proto(
use Protocol::{Tls, Ws, Wss};

let (last, next_last) = (addr.pop(), addr.into_iter().last());
let err = Err(format!("{} is not a websocket multiaddr", addr));
match (last, next_last) {
(Some(p1 @ Wss(_)), Some(p2)) if p2 != Tls => Ok((true, p1, addr)),
(Some(Ws(ref s)), Some(Tls)) => Ok((true, Protocol::Wss(s.clone()), addr)),
(Some(Ws(ref s)), Some(Tls)) => Ok((true, Wss(s.clone()), addr)),
(Some(ref p @ Ws(_)), Some(_)) => Ok((false, p.clone(), addr)),
(Some(Wss(_)), Some(Tls)) | _ => Err(format!("{} is not a websocket multiaddr", addr)),
(Some(Wss(_)), Some(Tls)) => err,
_ => err,
}
}

Expand Down

0 comments on commit 2a6748f

Please sign in to comment.