sindresorhus / pageres

Capture website screenshots
MIT License
9.68k stars 744 forks source link

pageres-cli doesn't recognize local file paths starting with ./ or ../ #415

Closed php4fan closed 3 years ago

php4fan commented 3 years ago

From the docs at https://github.com/sindresorhus/pageres-cli:

# <url> can also be a local file path.
pageres <file> <resolution>

To me "local file path" means any valid local file path, either absolute or relative, unless otherwise specified.

However, these don't work:

pageres ./test.html
pageres ../somefolder/test.html 

It produces these errors:

TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:363:5)
    at onParseError (node:internal/url:536:9)
    at new URL (node:internal/url:612:5)
    at normalizeUrl (/home/nodenpm/.npm-global/lib/node_modules/pageres-cli/node_modules/normalize-url/index.js:109:17)
    at module.exports (/home/nodenpm/.npm-global/lib/node_modules/pageres-cli/node_modules/humanize-url/index.js:9:9)
    at filenamifyUrl (/home/nodenpm/.npm-global/lib/node_modules/pageres-cli/node_modules/filenamify-url/index.js:10:39)
    at Pageres.create (/home/nodenpm/.npm-global/lib/node_modules/pageres-cli/node_modules/pageres/dist/index.js:188:21)
    at pMap.concurrency (/home/nodenpm/.npm-global/lib/node_modules/pageres-cli/node_modules/pageres/dist/index.js:106:29)
    at /home/nodenpm/.npm-global/lib/node_modules/pageres-cli/node_modules/p-map/index.js:57:28 {
  input: './test.html',
  code: 'ERR_INVALID_URL'

At the very least this is not properly documented, but I don't see a good reason why it shouldn't actually work.

sindresorhus commented 3 years ago

https://github.com/sindresorhus/pageres/releases/tag/v6.2.3

Just reinstalled the CLI to get the fix.