Skip to content

Fix for https:// and ftp:// URLs #6

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

Merged
merged 2 commits into from
Apr 3, 2012

Conversation

mattclements
Copy link
Contributor

Added Fix to allow https:// and ftp:// URL's (Issue #5)

I suppose we need to look at the possibility of passing protocol lists to the validation rules so you can enable ftp:// etc when required.

@victorjonsson
Copy link
Owner

Thank you for your contribution Matt!

There's one thing I find a bit odd though. I see that you have changed the way of comparing variables, always using === or !==. Is this something proposed by JSLint? Please point me to some articles discussing why this necessary. I dont see why typeof (var) === 'undefined' is preffered over == 'undefined', since there's no risk of problems with type casting that case.

victorjonsson added a commit that referenced this pull request Apr 3, 2012
Fix for https:// and ftp:// URLs
@victorjonsson victorjonsson merged commit 6972774 into victorjonsson:master Apr 3, 2012
@mattclements
Copy link
Contributor Author

No problem - Glad I can help, I am going to put together some more bits for the plugin over the next few days such as UK Date formats, UK Postcodes etc.

Details about the === vs == : http://stackoverflow.com/questions/359494/javascript-vs-does-it-matter-which-equal-operator-i-use

Basically as no type conversion will be taking place this makes the comparison slightly faster. Also if the type is ever incorrect this will instantly fail, rather than bloating while trying to convert the variable.

@victorjonsson
Copy link
Owner

Oh, that sounds great! If you can find out how to easily translate different date formats it would be greatly appriciated. At the moment the plugin only supports two different date formats. The code only decides whether to use either yyyy-mm-dd or dd/mm/yyyy, it has no greater understanding of what the formatted string actually means.

Regarding the "equal" operator. In my opinion the type conversion never becomes an issue as long as the programmer doesn't becmoe sloppy. If there's a risk of type conversion messing up the outcome of an if-statement the ===/!== should be used. In the case of typeof(var) == 'something' I know that typeof() returns a string which means that no type conversion will take place when Im comparing it with another string, or am I wrong?

I know that Mr. Crockfords words is considered "law" by many but I'm having problems accepting that I should use === when Im using a native javascript function (becaus its native I can feel sure about what it will return).

@mattclements
Copy link
Contributor Author

Brilliant,

I agree with you entirely with regards to the "equal" operator. I guess due to working on lots of projects that are then handed over to a "sloppy" programmer/web guy/everything else once I have finished a clients project I always use === to make sure if they make changes to the inputs by a function etc then this will continue to work correctly.

Basically it is no worse using === than ==, and it can be faster/safer to use if somebody hacks around with the code.

@victorjonsson
Copy link
Owner

+1

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

Successfully merging this pull request may close these issues.

2 participants