-
19 Oct 2012 1:26 PM #1
URL vtype should not allow spaces
URL vtype should not allow spaces
Using ExtJS 4.1.1
The url vtype thinks the following URL is valid:
http://www.grammar school.com
-
20 Oct 2012 6:10 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
Thanks for the report! I have opened a bug in our bug tracker.
-
22 Oct 2012 7:31 AM #3
The interesting thing here is that the regex for urls does not allow spaces. But Javascript's test() method for regex returns true if is testing a string that contains substrings that match the regex (and those substrings are only separated by whitespace.)
http://www.grammar school.com
returns true because the following strings match the regex:
['http://www.grammar', 'school.com']
Here is my workaround: use the same regex, but use exec() instead of test(). The url regex is the same - it is copied because I did not have scope access to the original regex in the VType closure.
Code:Ext.override(Ext.form.field.VTypes, { urlRegex: /(((^https?)|(^ftp)):\/\/((([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*)|(localhost|LOCALHOST))\/?)/i, 'url': function(urlToTest) { var urlMatches = this.urlRegex.exec(urlToTest); if(urlMatches && urlMatches.length > 0) { return (urlMatches[0] === urlToTest); } else { return false; } } });
You found a bug! We've classified it as
EXTJSIV-7566
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote