Skip to content

Commit

Permalink
Add support for .rbl extensions in urls
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Mar 17, 2024
1 parent 444e33d commit aba2926
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions crates/re_data_source/src/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use anyhow::Context as _;
#[derive(Debug, Clone)]
pub enum DataSource {
/// A remote RRD file, served over http.
///
/// Could be either an `.rrd` recording or a `.rbl` blueprint.
RrdHttpUrl(String),

/// A path to a local file.
Expand Down Expand Up @@ -86,7 +88,7 @@ impl DataSource {
DataSource::FilePath(file_source, path)
} else if uri.starts_with("http://")
|| uri.starts_with("https://")
|| (uri.starts_with("www.") && uri.ends_with(".rrd"))
|| (uri.starts_with("www.") && (uri.ends_with(".rrd") || uri.ends_with(".rbl")))
{
DataSource::RrdHttpUrl(uri)
} else if uri.starts_with("ws://") || uri.starts_with("wss://") {
Expand All @@ -95,7 +97,7 @@ impl DataSource {
// Now we are into heuristics territory:
} else if looks_like_a_file_path(&uri) {
DataSource::FilePath(file_source, path)
} else if uri.ends_with(".rrd") {
} else if uri.ends_with(".rrd") || uri.ends_with(".rbl") {
DataSource::RrdHttpUrl(uri)
} else {
// If this is sometyhing like `foo.com` we can't know what it is until we connect to it.
Expand Down Expand Up @@ -234,6 +236,7 @@ fn test_data_source_from_uri() {
"https://foo.zip",
"example.zip/foo.rrd",
"www.foo.zip/foo.rrd",
"www.foo.zip/blueprint.rbl",
];
let ws = ["ws://foo.zip", "wss://foo.zip", "127.0.0.1"];

Expand Down
4 changes: 3 additions & 1 deletion crates/re_viewer/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ pub fn set_email(email: String) {

enum EndpointCategory {
/// Could be a local path (`/foo.rrd`) or a remote url (`http://foo.com/bar.rrd`).
///
/// Could be a link to either an `.rrd` recording or a `.rbl` blueprint.
HttpRrd(String),

/// A remote Rerun server.
Expand All @@ -232,7 +234,7 @@ enum EndpointCategory {
}

fn categorize_uri(uri: &str) -> EndpointCategory {
if uri.starts_with("http") || uri.ends_with(".rrd") {
if uri.starts_with("http") || uri.ends_with(".rrd") || uri.ends_with(".rbl") {
EndpointCategory::HttpRrd(uri.into())
} else if uri.starts_with("ws:") || uri.starts_with("wss:") {
EndpointCategory::WebSocket(uri.into())
Expand Down

0 comments on commit aba2926

Please sign in to comment.