url_absolute fails with spaces in url
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 48/100
Direzione di ricerca
Start by reproducing the reported url_absolute() examples with spaces and with utils::URLencode(), then inspect the url_absolute() entry point and its handling of invalid URLs. Clarify whether the expected result is encoding the spaces or warning instead of returning NA, and add regression coverage showing that URLs with spaces no longer fail silently.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
xml_attr(x, "href") returns un-encoded URLs if that's how they appear in the source, but then those URLs fail in url_absolute.
url <- "/filename with spaces.pdf"
xml2::url_absolute(
url,
base = "https://example.com/"
)
#> [1] NA
xml2::url_absolute(
utils::URLencode(url),
base = "https://example.com/"
)
#> [1] "https://example.com/filename%20with%20spaces.pdf"
Created on 2023-08-23 with reprex v2.0.2
url_absolute() gets confused if the URL contains spaces, and silently returns NA. This should at least warn the user, but it might be preferable to deal with it directly.
This is where I found it in the wild:
base_url <- "https://www.copyright.gov/fair-use/fair-index.html"
pdf_urls <-
rvest::read_html(base_url) |>
rvest::html_element("table") |>
rvest::html_elements("tr>td:first-of-type>a:first-of-type") |>
rvest::html_attr("href")
pdf_urls[[10]] |>
rvest::url_absolute(base_url)
#> [1] NA
pdf_urls[[10]] |>
utils::URLencode() |>
rvest::url_absolute(base_url)
#> [1] "https://www.copyright.gov/fair-use/summaries/ONeil%20v.%20Ratajkowski%20No.%2019%20CIV.%209769%20(S.D.N.Y.%202021).pdf"
Created on 2023-08-23 with reprex v2.0.2
- Lingua principale
- R
- Stelle
- 227
- Fork
- 86
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di r-lib/xml2
-
Export libxml2_version()Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 67/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
Optimize xml_path() and xml_find_all() for large node setsForse già presa @astruebi l’ha presa 182 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
Bioconductor/BiocParallel#289 ·
-
automation
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
waldronlab/BugSigDBcuration#2224 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
merliseclyde/BAS#118 ·