(function(global) { var define, requireModule, require, requirejs; (function() { var _isArray; if (!Array.isArray) { _isArray = function (x) { return Object.prototype.toString.call(x) === "[object Array]"; }; } else { _isArray = Array.isArray; } var registry = {}, seen = {}; var FAILED = false; var uuid = 0; function tryFinally(tryable, finalizer) { try { return tryable(); } finally { finalizer(); } } function Module(name, deps, callback, exports) { var defaultDeps = ['require', 'exports', 'module']; this.id = uuid++; this.name = name; this.deps = !deps.length && callback.length ? defaultDeps : deps; this.exports = exports || { }; this.callback = callback; this.state = undefined; } define = function(name, deps, callback) { if (!_isArray(deps)) { callback = deps; deps = []; } registry[name] = new Module(name, deps, callback); }; define.amd = {}; function reify(mod, name, seen) { var deps = mod.deps; var length = deps.length; var reified = new Array(length); var dep; // TODO: new Module // TODO: seen refactor var module = { }; for (var i = 0, l = length; i < l; i++) { dep = deps[i]; if (dep === 'exports') { module.exports = reified[i] = seen; } else if (dep === 'require') { reified[i] = require; } else if (dep === 'module') { mod.exports = seen; module = reified[i] = mod; } else { reified[i] = require(resolve(dep, name)); } } return { deps: reified, module: module }; } requirejs = require = requireModule = function(name) { var mod = registry[name]; if (!mod) { throw new Error('Could not find module ' + name); } if (mod.state !== FAILED && seen.hasOwnProperty(name)) { return seen[name]; } var reified; var module; var loaded = false; seen[name] = { }; // placeholder for run-time cycles tryFinally(function() { reified = reify(mod, name, seen[name]); module = mod.callback.apply(this, reified.deps); loaded = true; }, function() { if (!loaded) { mod.state = FAILED; } }); if (module === undefined && reified.module.exports) { return (seen[name] = reified.module.exports); } else { return (seen[name] = module); } }; function resolve(child, name) { if (child.charAt(0) !== '.') { return child; } var parts = child.split('/'); var nameParts = name.split('/'); var parentBase = nameParts.slice(0, -1); for (var i = 0, l = parts.length; i < l; i++) { var part = parts[i]; if (part === '..') { parentBase.pop(); } else if (part === '.') { continue; } else { parentBase.push(part); } } return parentBase.join('/'); } requirejs.entries = requirejs._eak_seen = registry; requirejs.clear = function(){ requirejs.entries = requirejs._eak_seen = registry = {}; seen = state = {}; }; })(); define("route-recognizer", ["route-recognizer/dsl","exports"], function(__dependency1__, __exports__) { "use strict"; var map = __dependency1__["default"]; var specials = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\' ]; var escapeRegex = new RegExp('(\\' + specials.join('|\\') + ')', 'g'); function isArray(test) { return Object.prototype.toString.call(test) === "[object Array]"; } // A Segment represents a segment in the original route description. // Each Segment type provides an `eachChar` and `regex` method. // // The `eachChar` method invokes the callback with one or more character // specifications. A character specification consumes one or more input // characters. // // The `regex` method returns a regex fragment for the segment. If the // segment is a dynamic of star segment, the regex fragment also includes // a capture. // // A character specification contains: // // * `validChars`: a String with a list of all valid characters, or // * `invalidChars`: a String with a list of all invalid characters // * `repeat`: true if the character specification can repeat function StaticSegment(string) { this.string = string; } StaticSegment.prototype = { eachChar: function(callback) { var string = this.string, ch; for (var i=0, l=string.length; i " + n.nextStates.map(function(s) { return s.debug() }).join(" or ") + " )"; }).join(", ") } END IF **/ // This is a somewhat naive strategy, but should work in a lot of cases // A better strategy would properly resolve /posts/:id/new and /posts/edit/:id. // // This strategy generally prefers more static and less dynamic matching. // Specifically, it // // * prefers fewer stars to more, then // * prefers using stars for less of the match to more, then // * prefers fewer dynamic segments to more, then // * prefers more static segments to more function sortSolutions(states) { return states.sort(function(a, b) { if (a.types.stars !== b.types.stars) { return a.types.stars - b.types.stars; } if (a.types.stars) { if (a.types.statics !== b.types.statics) { return b.types.statics - a.types.statics; } if (a.types.dynamics !== b.types.dynamics) { return b.types.dynamics - a.types.dynamics; } } if (a.types.dynamics !== b.types.dynamics) { return a.types.dynamics - b.types.dynamics; } if (a.types.statics !== b.types.statics) { return b.types.statics - a.types.statics; } return 0; }); } function recognizeChar(states, ch) { var nextStates = []; for (var i=0, l=states.length; i 2 && key.slice(keyLength -2) === '[]') { isArray = true; key = key.slice(0, keyLength - 2); if(!queryParams[key]) { queryParams[key] = []; } } value = pair[1] ? decodeURIComponent(pair[1]) : ''; } if (isArray) { queryParams[key].push(value); } else { queryParams[key] = value; } } return queryParams; }, recognize: function(path) { var states = [ this.rootState ], pathLen, i, l, queryStart, queryParams = {}, isSlashDropped = false; path = decodeURI(path); queryStart = path.indexOf('?'); if (queryStart !== -1) { var queryString = path.substr(queryStart + 1, path.length); path = path.substr(0, queryStart); queryParams = this.parseQueryString(queryString); } // DEBUG GROUP path if (path.charAt(0) !== "/") { path = "/" + path; } pathLen = path.length; if (pathLen > 1 && path.charAt(pathLen - 1) === "/") { path = path.substr(0, pathLen - 1); isSlashDropped = true; } for (i=0, l=path.length; i