define([ 'dojo/_base/declare', 'dojo/io-query' ],function(declare,ioQuery){ var _paramMatch = /:(\w[\w\d]*)/g; var _paramReplace = "([^\\/!]+)"; var Path = declare(null,{ _paramNames: null, _matcher: null, constructor: function(pattern) { var match = null; this._paramNames = []; while((match = _paramMatch.exec(pattern)) !== null){ this._paramNames.push(match[1]); } pattern = pattern.replace(_paramMatch, _paramReplace); this._matcher = new RegExp('^!'+pattern+'(!(.*))?$'); }, match: function(path) { var params = null; var result = null; if ((result = this._matcher.exec(path)) !== null) { var numParams = this._paramNames.length; params = {}; for (var j = 0; j < numParams; j++) { params[this._paramNames[j]] = result[j+1]; } if ( result.length > numParams+1 && result[numParams+2] ) { params.options = ioQuery.queryToObject(result[numParams+2]); } } return params; } }); Path.getDefault = function() { return "!/"; }; Path.format = function(path,options) { var hash = '!'+path; if ( options ) { hash += '!'+ioQuery.objectToQuery(options); } return hash; }; return Path; });