File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 8
8
-DIRTY_CLASS
9
9
*/
10
10
11
- var URL_REGEXP = / ^ ( f t p | h t t p | h t t p s ) : \/ \/ ( \w + : { 0 , 1 } \w * @ ) ? ( \S + ) ( : [ 0 - 9 ] + ) ? ( \/ | \/ ( [ \w # ! : . ? + = & % @ ! \- \/ ] ) ) ? $ / ;
11
+ var URL_REGEXP = / ^ ( ( ( f t p | h t t p s ? ) : \/ \/ ) ( w w w \. ) ? | w w w \. ) ( [ \d a - z - _ \. ] + ) ( [ a - z \. ] { 2 , 7 } ) ( [ \/ \w \. - _ \? \& # ] * ) * \/ ? $ / ;
12
12
var EMAIL_REGEXP = / ^ [ a - z 0 - 9 ! # $ % & ' * + / = ? ^ _ ` { | } ~ . - ] + @ [ a - z 0 - 9 - ] + ( \. [ a - z 0 - 9 - ] + ) * $ / i;
13
13
var NUMBER_REGEXP = / ^ \s * ( \- | \+ ) ? ( \d + | ( \d * ( \. \d * ) ) ) \s * $ / ;
14
14
var DATE_REGEXP = / ^ ( \d { 4 } ) - ( \d { 2 } ) - ( \d { 2 } ) $ / ;
Original file line number Diff line number Diff line change @@ -1697,6 +1697,22 @@ describe('input', function() {
1697
1697
expect ( URL_REGEXP . test ( 'http://server:123/path' ) ) . toBe ( true ) ;
1698
1698
expect ( URL_REGEXP . test ( '[email protected] ' ) ) . toBe ( false ) ;
1699
1699
} ) ;
1700
+
1701
+
1702
+ it ( 'should pass on valid url' , function ( ) {
1703
+ expect ( URL_REGEXP . test ( 'http://server:123/path' ) ) . toBe ( true ) ;
1704
+ expect ( URL_REGEXP . test ( 'http://foo.com/angular#directives' ) ) . toBe ( true ) ;
1705
+ expect ( URL_REGEXP . test ( 'www.angularjs.org' ) ) . toBe ( true ) ;
1706
+ expect ( URL_REGEXP . test ( 'http://localhost:8080/?angular=cool&i=loveit' ) ) . toBe ( true ) ;
1707
+ } ) ;
1708
+
1709
+
1710
+ it ( 'should fail on invalid url' , function ( ) {
1711
+ expect ( URL_REGEXP . test ( 'http://' ) ) . toBe ( false ) ;
1712
+ expect ( URL_REGEXP . test ( 'http://w' ) ) . toBe ( false ) ;
1713
+ expect ( URL_REGEXP . test ( 'http://www.angularjs. org' ) ) . toBe ( false ) ;
1714
+ expect ( URL_REGEXP . test ( 'htp://localhost:8080/?angular=cool&i=loveit' ) ) . toBe ( false ) ;
1715
+ } ) ;
1700
1716
} ) ;
1701
1717
} ) ;
1702
1718
You can’t perform that action at this time.
0 commit comments