Skip to content

Commit 6eafd16

Browse files
committed
modify plotly_domain env var when using API v2, fixes #441
1 parent f11482b commit 6eafd16

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

R/plotly_POST.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ plotly_POST <- function(x, filename, fileopt = "new",
7777
if (sharing[1] == "hidden") {
7878
bits <- strsplit(con$url, "/")[[1]]
7979
plot_id <- bits[length(bits)]
80-
url <- paste0(get_domain("v2"), "files/", verify("username"), ":", plot_id)
80+
url <- file.path(get_domain("v2"), "files", paste0(verify("username"), ":", plot_id))
8181
bod <- list(share_key_enabled = TRUE)
8282
con2 <- httr::PATCH(url, plotly_headers("v2"), body = bod, encode = "json")
8383
con$url <- paste0(con$url, "?share_key=", content(con2)$share_key)

R/utils.R

+7-6
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,14 @@ struct <- function(x, y, ...) {
184184

185185
# TODO: what are some other common configuration options we want to support??
186186
get_domain <- function(type = "main") {
187-
if (type == "stream") {
188-
Sys.getenv("plotly_streaming_domain", "http://stream.plot.ly")
189-
} else if (type == "v2") {
190-
Sys.getenv("plotly_domain", "https://api.plot.ly/v2/")
191-
} else {
192-
Sys.getenv("plotly_domain", "https://plot.ly")
187+
dom <- Sys.getenv("plotly_domain", "https://plot.ly")
188+
if (type == "v2") {
189+
u <- httr::parse_url(dom)
190+
u$hostname <- paste0("api.", u$hostname)
191+
u$path <- "v2"
192+
dom <- httr::build_url(u)
193193
}
194+
dom
194195
}
195196

196197
# plotly's special keyword arguments in POST body

man/plotly_POST.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)