`url_decode2` is not NA aware
Closed this issue · 5 comments
chainsawriot commented
adaR::url_decode2(NA)
#> [1] "NA"
Created on 2023-09-27 with reprex v2.0.2
Fixing this can also enable decoding in C++.
schochastics commented
@chainsawriot Do you mean something like
CharacterVector Rcpp_ada_get(const CharacterVector& url_vec, std::function<ada_string(ada_url)> func, bool decode) {
unsigned int n = url_vec.length();
CharacterVector out(n);
for (int i = 0; i < url_vec.length(); i++) {
String s = url_vec[i];
const char* input = s.get_cstring();
ada_url url = ada_parse(input, std::strlen(input));
if (!ada_is_valid(url)) {
out[i] = NA_STRING;
} else {
out[i] = charsub(func(url));
}
}
if(decode){
return(url_decode2(out))
}else{
return (out);
}
}
chainsawriot commented
yeah. I am eyeing on removing all of these
https://github.com/schochastics/adaR/blob/14692c751ac2fdbc97caa5b491357788d51eb7f6/R/parse.R#L20-L42
chainsawriot commented
url_decode2(NULL)
kills R.
chainsawriot commented
@schochastics Would you mind me changing url_decode2
with an R wrapper to filter the NULL case?
CharacterVector url_decode2(CharacterVector& url) {
if (url.isNULL()) {
CharacterVector output(0);
return output;
}
}
url_decode2(NULL)
still kills this. Tried also Rf_isNull
. It can't even pass the first line.
schochastics commented
@chainsawriot no go ahead and make that change