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

Protocol regex wrong? #132

Closed
hackerwins opened this issue Jan 13, 2014 · 5 comments
Closed

Protocol regex wrong? #132

hackerwins opened this issue Jan 13, 2014 · 5 comments
Labels

Comments

@hackerwins
Copy link

There is a problem with the regular expression to determine the protocol.

URI.protocol_expression = /^[a-z][a-z0-9-+-]*$/i;

https://github.com/medialize/URI.js/blob/gh-pages/src/URI.js#L172

How about changing -+- to -+\. ?

http://stackoverflow.com/questions/3641722/valid-characters-for-uri-schemes

@rodneyrehm
Copy link
Member

Not sure how that slipped by the tests. Good call. Do you want to send a PR?

@hackerwins
Copy link
Author

@rodneyrehm Thanks to reply. Yeap. 👍

@ooxi
Copy link

ooxi commented Jan 14, 2014

Shouln't -+\. be -+. since it is already in a character class?

P.S.: Not sure about the following but I head that - should be the last character in a character class since it has a special meaning for character ranges like a-z. So I would suggest using .+- instead of -+-

@rodneyrehm
Copy link
Member

It can, but it's not mandatory. I've made a habit of escaping things in character classes as well. and yes, if - is not escaped, it must come last.

@rodneyrehm
Copy link
Member

The issue is resolved in v1.12.0

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

3 participants