Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled rejection URIError: URI malformed #22

Closed
bonustrack opened this issue Sep 9, 2017 · 3 comments
Closed

Unhandled rejection URIError: URI malformed #22

bonustrack opened this issue Sep 9, 2017 · 3 comments

Comments

@bonustrack
Copy link

I found an url that make get-urls throw an error

Unhandled rejection URIError: URI malformed

To reproduce the issue, parse this string with get-urls:

Hello http://example.com/D%C9PLIANT World

%C9 is used to create an accent in french.

@sindresorhus
Copy link
Owner

sindresorhus commented Sep 9, 2017

It's coming from: https://github.com/sindresorhus/normalize-url/blob/48b1864f8ef197df46abc380f55ca6f831d52fed/index.js#L84

This seems relevant: https://stackoverflow.com/questions/9064536/javascript-decodeuricomponent-malformed-uri-exception

This works, but I don't think that's a good solution:

decodeURI(unescape('http://example.com/D%C9PLIANT'))

@MortenHofft
Copy link

Thank you for a nice library.

var getUrls = require("get-urls");
var str = "https://a.bc/%";
getUrls(str); //fails
getUrls(decodeURI(unescape(str))); //fails as well

I would expect either no results if the url is indeed malformed

poltak added a commit to WorldBrain/Memex that referenced this issue May 14, 2018
- open issue upstream: sindresorhus/get-urls#22 - although this just reflects the browser API's behaviour: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Malformed_URI
- ensure to catch any errors thrown from `normalize-url` calls
- fallback to using the un-normalized URL if given URL has issues
@sindresorhus
Copy link
Owner

This was fixed by d3d0f29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants