Skip to content

Commit 0d6308d

Browse files
committed
add https-scheme to videochat-instance, if missing in pattern
1 parent b9afd25 commit 0d6308d

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

src/message.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -646,21 +646,36 @@ impl Message {
646646
// add room to a webrtc_instance as defined by the corresponding config-value;
647647
// the result may still be prefixed by the type
648648
pub fn create_webrtc_instance(instance: &str, room: &str) -> String {
649-
if instance.contains("$ROOM") {
650-
instance.replace("$ROOM", &room)
649+
let (videochat_type, mut url) = Message::parse_webrtc_instance(instance);
650+
651+
// make sure, there is a scheme in the url
652+
if !url.contains(":") {
653+
url = format!("https://{}", url);
654+
}
655+
656+
// add/replace room
657+
let url = if url.contains("$ROOM") {
658+
url.replace("$ROOM", &room)
651659
} else {
652-
// if there nothing that would separate the room, add a slash as a separator
660+
// if there nothing that would separate the room, add a slash as a separator;
653661
// this way, urls can be given as "https://meet.jit.si" as well as "https://meet.jit.si/"
654-
let maybe_slash = if instance.ends_with("/")
655-
|| instance.ends_with("?")
656-
|| instance.ends_with("#")
657-
|| instance.ends_with("=")
662+
let maybe_slash = if url.ends_with("/")
663+
|| url.ends_with("?")
664+
|| url.ends_with("#")
665+
|| url.ends_with("=")
658666
{
659667
""
660668
} else {
661669
"/"
662670
};
663-
format!("{}{}{}", instance, maybe_slash, room)
671+
format!("{}{}{}", url, maybe_slash, room)
672+
};
673+
674+
// re-add and normalize type
675+
match videochat_type {
676+
VideochatType::BasicWebrtc => format!("basicwebrtc:{}", url),
677+
VideochatType::Jitsi => format!("jitsi:{}", url),
678+
_ => url,
664679
}
665680
}
666681

0 commit comments

Comments
 (0)