helpers: url() rejects a resolved URL whose path has an apostrophe

Open Beginner friendly
#901 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
86/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, node.js
Domain
backend, web-dev

Research direction

Read the url() helper and its isUrl validation in @metascraper/helpers, then inspect packages/metascraper-helpers/test/index.js. Add a test resolving a relative path against a page URL containing an apostrophe, and check that the resolved URL is returned; the issue is done when that case passes.

Written by the indexing model from the issue text.

Description

What happens

url() in @metascraper/helpers returns undefined for any relative value resolved against a page whose path contains ', so every relative image, logo or url on that page is dropped.

const { url } = require('@metascraper/helpers')
url('thumbs/DSCF0203.jpg', {
  url: "https://espagne.seville.af24.fr/L'alcazar/Palais%20du%20Roi%20Pedro/index.html"
})
// => undefined

new URL() resolves it fine (https://espagne.seville.af24.fr/L'alcazar/Palais%20du%20Roi%20Pedro/thumbs/DSCF0203.jpg), but isUrl (url-regex-safe, exact: true) rejects the ', which RFC 3986 allows in a path (sub-delims).

Who gets it

Found while fixing #899: on that page the real image (data-src="thumbs/DSCF0203.jpg", also src once rendered) is rejected, while ../../res/blank.png resolved outside the apostrophe segment and was returned. With #899 fixed the page answers image: null instead of the real thumbnail.

Done when

url() keeps a resolved URL with ' in its path, with a test in packages/metascraper-helpers/test/index.js.

🤖 Generated with Claude Code

Dominant language
HTML
Stars
2.8k
Forks
183
Avg merge
1h 16m
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microlinkhq/metascraper

All issues in microlinkhq/metascraper

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.