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
withinString may throw an exception on malformed urls #359
Comments
Okay my bad on this one, it throws the exception within |
It's not the same as #352 as that was caused by an unfortunate change in URI.js v1.18.11 (and reverted in v1.19.0). What is the exact input you're dealing with here? You'll probably want to make sure that the URI.withinString(text, function(uri) {
try {
var u = new URI(uri);
// …
} catch (error) {
// ignore the uri
return undefined;
}
}); |
@rodneyrehm FYI the workaround described above works but the type for withinString does not permit an undefined return value |
@luisnaranjo733 what type? if you're referring to TypeScript you're looking for https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/urijs as this project is currently not providing type definitions itself. |
Basically this function is not safe enough to be called on user input as it may crash with "URI malformed" which is thrown by nodejs' implementation of
decodeURIComponent
Right now the only suitable solution I see is wrapping it in a try/catch, which somewhat defeats the purpose of this function.
A link that throws:
http://a:%p@c
The text was updated successfully, but these errors were encountered: