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

URI.withinString matches www. #327

Closed
Bonuspunkt opened this issue Feb 13, 2017 · 6 comments
Closed

URI.withinString matches www. #327

Bonuspunkt opened this issue Feb 13, 2017 · 6 comments
Labels

Comments

@Bonuspunkt
Copy link

code

const URI = require("urijs");
const text = "world wide web is abbreviated with www.";
URI.withinString(text, function(url) {
	console.log(text);
	console.log(url);
});

output

world wide web is abbreviated with www.
www
@rodneyrehm
Copy link
Member

Hehe, I just fixed that in my local rewrite-URI-in-ES6-playground the other day :D - for what it's worth, http://. is another false positive…

@rodneyrehm
Copy link
Member

@Bonuspunkt I looked at the referenced issue's code and saw your const incorrectDetections = ["www"]; hack. You could've used URI.withinString(text, callback, { ignore: /^www\.$/ });.

Could you explain the commonSchemes thing you've got going there? what exactly are you doing here?

@Bonuspunkt
Copy link
Author

Bonuspunkt commented Feb 13, 2017

came from an issue with look at...http://example.com (correctly) returning at...http://example.com.
so if a scheme ends with ex. http everything before that gets ignored when returning the url (would be http://example.com in this example)

@rodneyrehm
Copy link
Member

In an attempt to fix bad user input at..http://example.org (missing space after punctuation), your current implementation accidentally breaks valid URLs like svn+ssh://example.org. Although I'm not aware of many protocols in the form of svn+ssh, and I've not witnessed this in the wild, most systems allow applications to register custom schemes. Even browsers allow web apps to handle custom schemes like web+gustav. Bad input is bad input and assuming users would quickly realize their mistake, I'd not try to fix this.

I'll have a fix for the original www. problem shortly

@rodneyrehm
Copy link
Member

fix released as v1.18.7 :)

@Bonuspunkt
Copy link
Author

Bonuspunkt commented Feb 13, 2017

❤️

thanks for pointing out the svn+ssh.
its used in an irc client, send messages can't be edited an you are >90% on the receiving end.
so this ends up as UX vs. 100% correctness.

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

No branches or pull requests

2 participants