src/services/state-router.js
function(query, params) {
        query = query || '';
        
        // No state
        if(!_current) {
          return false;

        // Use RegExp matching
        } else if(query instanceof RegExp) {
          return !!_current.name.match(query);

        // String; state dot-notation
        } else if(typeof query === 'string') {

          // Cast string to RegExp
          if(query.match(/^\/.*\/$/)) {
            var casted = query.substr(1, query.length-2);
            return !!_current.name.match(new RegExp(casted));

          // Transform to state notation
          } else {
            var transformed = query
              .split('.')
              .map(function(item) {
                if(item === '*') {
                  return '[a-zA-Z0-9_]*';
                } else if(item === '**') {
                  return '[a-zA-Z0-9_\\.]*';
                } else {
                  return item;
                }
              })
              .join('\\.');

            return !!_current.name.match(new RegExp(transformed));
          }
        }

        // Non-matching
        return false;
      }
function(query, params) {
        query = query || '';
        
        // No state
        if(!_current) {
          return false;

        // Use RegExp matching
        } else if(query instanceof RegExp) {
          return !!_current.name.match(query);

        // String; state dot-notation
        } else if(typeof query === 'string') {

          // Cast string to RegExp
          if(query.match(/^\/.*\/$/)) {
            var casted = query.substr(1, query.length-2);
            return !!_current.name.match(new RegExp(casted));

          // Transform to state notation
          } else {
            var transformed = query
              .split('.')
              .map(function(item) {
                if(item === '*') {
                  return '[a-zA-Z0-9_]*';
                } else if(item === '**') {
                  return '[a-zA-Z0-9_\\.]*';
                } else {
                  return item;
                }
              })
              .join('\\.');

            return !!_current.name.match(new RegExp(transformed));
          }
        }

        // Non-matching
        return false;
      }
function ( query , params ) { query = query || '' ; // No state if ( ! _current ) { return false ; // Use RegExp matching } else if ( query instanceof RegExp ) { return ! ! _current . name . match ( query ) ; // String; state dot-notation } else if ( typeof query === 'string' ) { // Cast string to RegExp if ( query . match ( / ^\/.*\/$ / ) ) { var casted = query . substr ( 1 , query . length - 2 ) ; return ! ! _current . name . match ( new RegExp ( casted ) ) ; // Transform to state notation } else { var transformed = query . split ( '.' ) . map ( function ( item ) { if ( item === '*' ) { return '[a-zA-Z0-9_]*' ; } else if ( item === '**' ) { return '[a-zA-Z0-9_\\.]*' ; } else { return item ; } } ) . join ( '\\.' ) ; return ! ! _current . name . match ( new RegExp ( transformed ) ) ; } } // Non-matching return false ; }
Check query against current state

@param  {Mixed}   query  A string using state notation or a RegExp
@param  {Object}  params A parameters data object
@return {Boolean}        A true if state is parent to current state
Check query against current state