USAID-OHA-SI / glamr

SI Utilities
https://usaid-oha-si.github.io/glamr/
Other
2 stars 3 forks source link

Bug with datim_dim_item #60

Closed achafetz closed 2 years ago

achafetz commented 2 years ago

Running datim_dim_items() with any dimension, the user receives the following error:

Error in stri_detect_regex(string, pattern, negate = negate, opts_regex = opts(pattern)) : Syntax error in regex pattern. (U_REGEX_RULE_SYNTAX, context=?paging)

Solution: I think the ? just needs to be escaped \\?

FYI @baboyma

achafetz commented 2 years ago

This seems the location of the errror.

https://github.com/USAID-OHA-SI/glamr/blob/5b834792751235d530a05bd683c166958d23a885/R/extract_datim.R#L126-L127

Adding the escape to resolve.

@baboyma, ln126 should not have a negation sign, correct? you want to remove paging for the url if it exists. which begs the question, is the if statement necessary? the str_remove() statement can be run regardless and will have no sign effects if paging already doesn't exist (and should be pretty fast)

I think the correct code should be

if (stringr::str_detect(url, "\\?paging")) 
  url <- stringr::str_remove(url, "\\?paging=(true|false)") 

And will implement without the if statement

url <- stringr::str_remove(url, "\\?paging=(true|false)")