examples/todo/js/services/router.js
function parseRoutes() {
		// Regexs to convert a route (/file/:fileId) into a regex
		var optionalParam = /\((.*?)\)/g,
			namedParam    = /(\(\?)?:\w+/g,
			splatParam    = /\*\w+/g,
			escapeRegExp  = /[\-{}\[\]+?.,\\\^$|#\s]/g,
			namedParamCallback = function(match, optional) {
				return optional ? match : '([^\/]+)';
			},
			route,
			regexRoute;

		for (var i = 0, len = pageRoutes.length; i < len; i++) {
			route = pageRoutes[i];
			regexRoute = route.replace(escapeRegExp, '\\$&')
						.replace(optionalParam, '(?:$1)?')
						.replace(namedParam, namedParamCallback)
						.replace(splatParam, '(.*?)');
			regexRoutes.push(new RegExp('^' + regexRoute + '$'));
		}
	}
function parseRoutes() {
		// Regexs to convert a route (/file/:fileId) into a regex
		var optionalParam = /\((.*?)\)/g,
			namedParam    = /(\(\?)?:\w+/g,
			splatParam    = /\*\w+/g,
			escapeRegExp  = /[\-{}\[\]+?.,\\\^$|#\s]/g,
			namedParamCallback = function(match, optional) {
				return optional ? match : '([^\/]+)';
			},
			route,
			regexRoute;

		for (var i = 0, len = pageRoutes.length; i < len; i++) {
			route = pageRoutes[i];
			regexRoute = route.replace(escapeRegExp, '\\$&')
						.replace(optionalParam, '(?:$1)?')
						.replace(namedParam, namedParamCallback)
						.replace(splatParam, '(.*?)');
			regexRoutes.push(new RegExp('^' + regexRoute + '$'));
		}
	}
function parseRoutes ( ) { // Regexs to convert a route (/file/:fileId) into a regex var optionalParam = / \((.*?)\) / g , namedParam = / (\(\?)?:\w+ / g , splatParam = / \*\w+ / g , escapeRegExp = / [\-{}\[\]+?.,\\\^$|#\s] / g , namedParamCallback = function ( match , optional ) { return optional ? match : '([^\/]+)' ; } , route , regexRoute ; for ( var i = 0 , len = pageRoutes . length ; i < len ; i ++ ) { route = pageRoutes [ i ] ; regexRoute = route . replace ( escapeRegExp , '\\$&' ) . replace ( optionalParam , '(?:$1)?' ) . replace ( namedParam , namedParamCallback ) . replace ( splatParam , '(.*?)' ) ; regexRoutes . push ( new RegExp ( '^' + regexRoute + '$' ) ) ; } }
Parses the user-friendly declared routes at the top of the application,
these could be init'ed or passed in from another context to help extract
navigation for T3 from the framework. Populates the regexRoutes variable
that is local to the service.
Regexs and parsing borrowed from Backbone's router since they did it right
and not inclined to make a new router syntax unless we have a reason to.
@returns {void}
Parses the user - friendly declared routes at the top of the application these could be init ed or passed in from another context to help extract navigation for T3 from the framework . Populates the regexRoutes variable that is local to the service . Regexs and parsing borrowed from Backbone s router since they did it right and not inclined to make a new router syntax unless we have a reason to .