1
1
/**
2
2
* State-based routing for AngularJS
3
- * @version v0.0.1 - 2013-02-15
3
+ * @version v0.0.1 - 2013-02-17
4
4
* @link
5
5
* @license MIT License, http://www.opensource.org/licenses/MIT
6
6
*/
@@ -147,6 +147,8 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
147
147
// Derive parent state from a hierarchical name only if 'parent' is not explicitly defined.
148
148
var parent = root ;
149
149
if ( ! isDefined ( state . parent ) ) {
150
+ // regex matches any valid composite state name
151
+ // would match "contact.list" but not "contacts"
150
152
var compositeName = / ^ ( .+ ) \. [ ^ . ] + $ / . exec ( name ) ;
151
153
if ( compositeName != null ) {
152
154
parent = findState ( compositeName [ 1 ] ) ;
@@ -572,11 +574,11 @@ function UrlMatcher(pattern) {
572
574
// inside the regular expression. The placeholder regexp breaks down as follows:
573
575
// :(\w+) colon placeholder ($1)
574
576
// \{(\w+)(?:\:( ... ))?\} curly brace placeholder ($2) with optional regexp ... ($3)
575
- // (?: ... | ... | ... )* the regexp consists of any number of atoms, an atom being either
577
+ // (?: ... | ... | ... )+ the regexp consists of any number of atoms, an atom being either
576
578
// [^{}\\]+ - anything other than curly braces or backslash
577
579
// \\. - a backslash escape
578
580
// \{(?:[^{}\\]+|\\.)*\} - a matched set of curly braces containing other atoms
579
- var placeholder = / : ( \w + ) | \{ ( \w + ) (?: \: ( (?: [ ^ { } \\ ] + | \\ .| \{ (?: [ ^ { } \\ ] + | \\ .) * \} ) * ) ) ? \} / g,
581
+ var placeholder = / : ( \w + ) | \{ ( \w + ) (?: \: ( (?: [ ^ { } \\ ] + | \\ .| \{ (?: [ ^ { } \\ ] + | \\ .) * \} ) + ) ) ? \} / g,
580
582
names = { } , compiled = '^' , last = 0 , m ,
581
583
segments = this . segments = [ ] ,
582
584
params = this . params = [ ] ;
@@ -598,8 +600,8 @@ function UrlMatcher(pattern) {
598
600
// The number of segments is always 1 more than the number of parameters.
599
601
var id , regexp , segment ;
600
602
while ( ( m = placeholder . exec ( pattern ) ) ) {
601
- id = ( m [ 1 ] != null ) ? m [ 1 ] : m [ 2 ] ;
602
- regexp = ( m [ 3 ] != null ) ? m [ 3 ] : '[^/]*' ;
603
+ id = m [ 1 ] || m [ 2 ] ;
604
+ regexp = m [ 3 ] || '[^/]*' ;
603
605
segment = pattern . substring ( last , m . index ) ;
604
606
if ( segment . indexOf ( '?' ) >= 0 ) break ; // we're into the search part
605
607
compiled += quoteRegExp ( segment ) + '(' + regexp + ')' ;
0 commit comments