Skip to content

Commit

Permalink
fix: ensure panic if the scheme is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Nov 21, 2024
1 parent ea63e39 commit 7be2959
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions crates/torii/graphql/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ fn graphql_filter(
);

let (graphql_endpoint, subscription_endpoint) = if let Some(external_url) = external_url {
let mut graphql_url = external_url.clone();
let mut graphql_url = external_url;
graphql_url.set_path("graphql");

Check warning on line 53 in crates/torii/graphql/src/server.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/graphql/src/server.rs#L51-L53

Added lines #L51 - L53 were not covered by tests

let mut websocket_url = external_url;
websocket_url.set_path("graphql/ws");
let _ =
websocket_url.set_scheme(if websocket_url.scheme() == "https" { "wss" } else { "ws" });
let mut websocket_url = graphql_url.clone();
websocket_url.set_path("ws");
let _ = websocket_url.set_scheme(match websocket_url.scheme() {

Check warning on line 57 in crates/torii/graphql/src/server.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/graphql/src/server.rs#L55-L57

Added lines #L55 - L57 were not covered by tests
"https" => "wss",
"http" => "ws",
_ => panic!("Invalid URL scheme - must be http or https"),

Check warning on line 60 in crates/torii/graphql/src/server.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/graphql/src/server.rs#L59-L60

Added lines #L59 - L60 were not covered by tests
});

(graphql_url.path().to_string(), websocket_url.to_string())

Check warning on line 63 in crates/torii/graphql/src/server.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/graphql/src/server.rs#L63

Added line #L63 was not covered by tests
} else {
Expand Down

0 comments on commit 7be2959

Please sign in to comment.