url_absolute fails with spaces in url
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- R
- Star
- 227
- Fork
- 86
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của r-lib/xml2
-
Export libxml2_version()Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 67/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
Optimize xml_path() and xml_find_all() for large node setsCó thể đã có người làm @astruebi đã nhận 182 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Bioconductor/BiocParallel#289 ·
-
automation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
waldronlab/BugSigDBcuration#2224 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
merliseclyde/BAS#118 ·