diff --git a/R/conn.R b/R/conn.R index 0eaf6c95..9967acf3 100644 --- a/R/conn.R +++ b/R/conn.R @@ -167,7 +167,19 @@ neuprint_connection <- function(server=NULL, token=NULL, dataset=NULL, # Set a default server if none specified neuprint_server <- if(is.null(server)) unlist(getenvoroption("server")) else server - # Set a default server if none specified + pu=httr::parse_url(neuprint_server) + if(is.null(pu$scheme)) { + pu$scheme="https" + if(is.null(pu$hostname)) { + pu$hostname=pu$path + pu$path=NULL + } + neuprint_server=httr::build_url(pu) + warning("No URL scheme specified for your server! Assuming it should be:x\n", + neuprint_server, + "\nPlease specify the URL in full next time!") + } + # Set a default token if none specified neuprint_token <- if(is.null(token)) unlist(getenvoroption("token")) else token # collect any curl options defined as environment variables config=neuprint_curl_options(config) diff --git a/tests/testthat/test-conn.R b/tests/testthat/test-conn.R index beb9a549..d1b83cd3 100644 --- a/tests/testthat/test-conn.R +++ b/tests/testthat/test-conn.R @@ -3,3 +3,11 @@ skip_if(as.logical(Sys.getenv("SKIP_NP_SERVER_TESTS"))) test_that("neuprint_login works", { expect_error(neuprint_login(server="https://neuprint.janelia.org", dataset='rhubarb')) }) + +test_that("neuprint_connection works", { + expect_warning(expect_is( + neuprint_connection(server = "neuprint.janelia.org", dataset = 'rhubarb'), + "neuprint_connection" + ), + regexp = "https://neuprint.janelia.org") +})