Why does utils::modifyList replace %20 with %2520 in a url object?

风流意气都作罢 提交于 2020-03-05 00:35:32

问题


It appears that a new bug has appeared in a package traits that I have been using and contributing to for a few years. It used to be that I use a query with a space character, and when the package returned a url, it would replace the space with %20, and the query would work.

So, I would like users to pass the argument as Test 1 and this used to be converted behind the scenes to Test%201 which the api was happy enough to resolve. But by the time the argument gets to the httr::handle_url function, it has been changed from Test 1 to Test%201 and then the function modifyList replaces the %20 with %2520, thus:

Minimal Reproducible Example

old <- structure(list(scheme = "https", hostname = "example.com"), class = "url")
new <- list(query = list(queryparameter = "Test%204"))
modifyList(old, new)

Actual use case

# install.packages('traits')
library(traits)
options(betydb_url = "https://terraref.org/bety/",
        betydb_api_version = 'v1')
season_4 <- betydb_query(sitename  = "~Season 4",
                         limit     =  'none')

Update I realized that the url redirects from terraref.org --> terraref.ncsa.illinois.edu, and the code works when I use the target. However, this does not seem to answer my question about why modifyList has this behavior

Questions

  • Why is the function modifyList replacing %20 with %2520 and
  • Why has this appeared in the last few months and
  • How can I fix it?

来源:https://stackoverflow.com/questions/60160208/why-does-utilsmodifylist-replace-20-with-2520-in-a-url-object

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!