From cf03be4b6fd916a105d4b2712cab0afd534691a8 Mon Sep 17 00:00:00 2001 From: EisenbergEffect Date: Wed, 13 Jun 2018 22:48:24 -0700 Subject: [PATCH] chore(all): prepare release 1.2.0 --- bower.json | 2 +- dist/amd/aurelia-route-recognizer.js | 79 ++++++++----------- dist/aurelia-route-recognizer.d.ts | 2 +- dist/aurelia-route-recognizer.js | 78 +++++++++--------- dist/commonjs/aurelia-route-recognizer.js | 79 ++++++++----------- dist/es2015/aurelia-route-recognizer.js | 62 +++++++-------- .../aurelia-route-recognizer.js | 79 ++++++++----------- dist/system/aurelia-route-recognizer.js | 79 ++++++++----------- doc/CHANGELOG.md | 10 +++ doc/api.json | 2 +- package.json | 2 +- 11 files changed, 221 insertions(+), 253 deletions(-) diff --git a/bower.json b/bower.json index 978aed7..31eb544 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-route-recognizer", - "version": "1.1.1", + "version": "1.2.0", "description": "A lightweight JavaScript library that matches paths against registered routes. It includes support for dynamic and star segments and nested handlers.", "keywords": [ "aurelia", diff --git a/dist/amd/aurelia-route-recognizer.js b/dist/amd/aurelia-route-recognizer.js index 0fc1e63..f582e37 100644 --- a/dist/amd/aurelia-route-recognizer.js +++ b/dist/amd/aurelia-route-recognizer.js @@ -128,7 +128,7 @@ define(['exports', 'aurelia-path'], function (exports, _aureliaPath) { }; DynamicSegment.prototype.regex = function regex() { - return this.optional ? '([^/]+)?' : '([^/]+)'; + return '([^/]+)'; }; DynamicSegment.prototype.generate = function generate(params, consumed) { @@ -199,12 +199,12 @@ define(['exports', 'aurelia-path'], function (exports, _aureliaPath) { } var currentState = this.rootState; + var skippableStates = []; var regex = '^'; var types = { statics: 0, dynamics: 0, stars: 0 }; var names = []; var routeName = route.handler.name; var isEmpty = true; - var isAllOptional = true; var segments = parse(route.path, names, types, route.caseSensitive); for (var i = 0, ii = segments.length; i < ii; i++) { @@ -213,25 +213,30 @@ define(['exports', 'aurelia-path'], function (exports, _aureliaPath) { continue; } - isEmpty = false; - isAllOptional = isAllOptional && segment.optional; + var _addSegment = addSegment(currentState, segment), + firstState = _addSegment[0], + nextState = _addSegment[1]; - currentState = addSegment(currentState, segment); - regex += segment.optional ? '/?' : '/'; - regex += segment.regex(); - } + for (var j = 0, jj = skippableStates.length; j < jj; j++) { + skippableStates[j].nextStates.push(firstState); + } - if (isAllOptional) { - if (isEmpty) { - currentState = currentState.put({ validChars: '/' }); - regex += '/'; + if (segment.optional) { + skippableStates.push(nextState); + regex += '(?:/' + segment.regex() + ')?'; } else { - var finalState = this.rootState.put({ validChars: '/' }); - currentState.epsilon = [finalState]; - currentState = finalState; + currentState = nextState; + regex += '/' + segment.regex(); + skippableStates.length = 0; + isEmpty = false; } } + if (isEmpty) { + currentState = currentState.put({ validChars: '/' }); + regex += '/?'; + } + var handlers = [{ handler: route.handler, names: names }]; if (routeName) { @@ -244,6 +249,13 @@ define(['exports', 'aurelia-path'], function (exports, _aureliaPath) { } } + for (var _i3 = 0; _i3 < skippableStates.length; _i3++) { + var state = skippableStates[_i3]; + state.handlers = handlers; + state.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i'); + state.types = types; + } + currentState.handlers = handlers; currentState.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i'); currentState.types = types; @@ -345,9 +357,9 @@ define(['exports', 'aurelia-path'], function (exports, _aureliaPath) { } var solutions = []; - for (var _i3 = 0, _l = states.length; _i3 < _l; _i3++) { - if (states[_i3].handlers) { - solutions.push(states[_i3]); + for (var _i4 = 0, _l = states.length; _i4 < _l; _i4++) { + if (states[_i4].handlers) { + solutions.push(states[_i4]); } } @@ -454,25 +466,6 @@ define(['exports', 'aurelia-path'], function (exports, _aureliaPath) { nextStates.push.apply(nextStates, state.match(ch)); } - var skippableStates = nextStates.filter(function (s) { - return s.epsilon; - }); - - var _loop = function _loop() { - var newStates = []; - skippableStates.forEach(function (s) { - nextStates.push.apply(nextStates, s.epsilon); - newStates.push.apply(newStates, s.epsilon); - }); - skippableStates = newStates.filter(function (s) { - return s.epsilon; - }); - }; - - while (skippableStates.length > 0) { - _loop(); - } - return nextStates; } @@ -499,16 +492,12 @@ define(['exports', 'aurelia-path'], function (exports, _aureliaPath) { } function addSegment(currentState, segment) { - var state = currentState.put({ validChars: '/' }); + var firstState = currentState.put({ validChars: '/' }); + var nextState = firstState; segment.eachChar(function (ch) { - state = state.put(ch); + nextState = nextState.put(ch); }); - if (segment.optional) { - currentState.epsilon = currentState.epsilon || []; - currentState.epsilon.push(state); - } - - return state; + return [firstState, nextState]; } }); \ No newline at end of file diff --git a/dist/aurelia-route-recognizer.d.ts b/dist/aurelia-route-recognizer.d.ts index f865921..0e0c2d5 100644 --- a/dist/aurelia-route-recognizer.d.ts +++ b/dist/aurelia-route-recognizer.d.ts @@ -146,5 +146,5 @@ export declare class RouteRecognizer { * `isDynanic` values for the matched route(s), or undefined if no match * was found. */ - recognize(path: string): RecognizedRoute[] | undefined; + recognize(path: string): RecognizedRoute[] | void; } \ No newline at end of file diff --git a/dist/aurelia-route-recognizer.js b/dist/aurelia-route-recognizer.js index 74561a7..93f1f40 100644 --- a/dist/aurelia-route-recognizer.js +++ b/dist/aurelia-route-recognizer.js @@ -144,7 +144,7 @@ export class DynamicSegment { } regex(): string { - return this.optional ? '([^/]+)?' : '([^/]+)'; + return '([^/]+)'; } generate(params: Object, consumed: Object): string { @@ -236,12 +236,12 @@ export class RouteRecognizer { } let currentState = this.rootState; + let skippableStates = []; let regex = '^'; let types = { statics: 0, dynamics: 0, stars: 0 }; let names = []; let routeName = route.handler.name; let isEmpty = true; - let isAllOptional = true; let segments = parse(route.path, names, types, route.caseSensitive); for (let i = 0, ii = segments.length; i < ii; i++) { @@ -250,27 +250,38 @@ export class RouteRecognizer { continue; } - isEmpty = false; - isAllOptional = isAllOptional && segment.optional; - // Add a representation of the segment to the NFA and regex - currentState = addSegment(currentState, segment); - regex += segment.optional ? '/?' : '/'; - regex += segment.regex(); - } + let [firstState, nextState] = addSegment(currentState, segment); + + // add the first part of the next segment to the end of any skipped states + for (let j = 0, jj = skippableStates.length; j < jj; j++) { + skippableStates[j].nextStates.push(firstState); + } - if (isAllOptional) { - if (isEmpty) { - currentState = currentState.put({ validChars: '/' }); - regex += '/'; + // If the segment was optional we don't fast forward to the end of the + // segment, but we do hold on to a reference to the end of the segment + // for adding future segments. Multiple consecutive optional segments + // will accumulate. + if (segment.optional) { + skippableStates.push(nextState); + regex += `(?:/${segment.regex()})?`; + + // Otherwise, we fast forward to the end of the segment and remove any + // references to skipped segments since we don't need them anymore. } else { - let finalState = this.rootState.put({ validChars: '/' }); - currentState.epsilon = [ finalState ]; - currentState = finalState; - // Regex is ok because the first '/?' will match. + currentState = nextState; + regex += `/${segment.regex()}`; + skippableStates.length = 0; + isEmpty = false; } } + // An "all optional" path is technically empty since currentState is this.rootState + if (isEmpty) { + currentState = currentState.put({ validChars: '/' }); + regex += '/?'; + } + let handlers = [{ handler: route.handler, names: names }]; if (routeName) { @@ -283,6 +294,15 @@ export class RouteRecognizer { } } + // Any trailing skipped states need to be endpoints and need to have + // handlers attached. + for (let i = 0; i < skippableStates.length; i++) { + let state = skippableStates[i]; + state.handlers = handlers; + state.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i'); + state.types = types; + } + currentState.handlers = handlers; currentState.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i'); currentState.types = types; @@ -380,7 +400,7 @@ export class RouteRecognizer { * `isDynanic` values for the matched route(s), or undefined if no match * was found. */ - recognize(path: string): RecognizedRoute[] | undefined { + recognize(path: string): RecognizedRoute[] | void { let states = [this.rootState]; let queryParams = {}; let isSlashDropped = false; @@ -533,16 +553,6 @@ function recognizeChar(states, ch) { nextStates.push(...state.match(ch)); } - let skippableStates = nextStates.filter(s => s.epsilon); - while (skippableStates.length > 0) { - let newStates = []; - skippableStates.forEach(s => { - nextStates.push(...s.epsilon); - newStates.push(...s.epsilon); - }); - skippableStates = newStates.filter(s => s.epsilon); - } - return nextStates; } @@ -569,15 +579,11 @@ function findHandler(state, path, queryParams) { } function addSegment(currentState, segment) { - let state = currentState.put({ validChars: '/' }); + let firstState = currentState.put({ validChars: '/' }); + let nextState = firstState; segment.eachChar(ch => { - state = state.put(ch); + nextState = nextState.put(ch); }); - if (segment.optional) { - currentState.epsilon = currentState.epsilon || []; - currentState.epsilon.push(state); - } - - return state; + return [firstState, nextState]; } diff --git a/dist/commonjs/aurelia-route-recognizer.js b/dist/commonjs/aurelia-route-recognizer.js index cca3ef6..9064a13 100644 --- a/dist/commonjs/aurelia-route-recognizer.js +++ b/dist/commonjs/aurelia-route-recognizer.js @@ -129,7 +129,7 @@ var DynamicSegment = exports.DynamicSegment = function () { }; DynamicSegment.prototype.regex = function regex() { - return this.optional ? '([^/]+)?' : '([^/]+)'; + return '([^/]+)'; }; DynamicSegment.prototype.generate = function generate(params, consumed) { @@ -200,12 +200,12 @@ var RouteRecognizer = exports.RouteRecognizer = function () { } var currentState = this.rootState; + var skippableStates = []; var regex = '^'; var types = { statics: 0, dynamics: 0, stars: 0 }; var names = []; var routeName = route.handler.name; var isEmpty = true; - var isAllOptional = true; var segments = parse(route.path, names, types, route.caseSensitive); for (var i = 0, ii = segments.length; i < ii; i++) { @@ -214,25 +214,30 @@ var RouteRecognizer = exports.RouteRecognizer = function () { continue; } - isEmpty = false; - isAllOptional = isAllOptional && segment.optional; + var _addSegment = addSegment(currentState, segment), + firstState = _addSegment[0], + nextState = _addSegment[1]; - currentState = addSegment(currentState, segment); - regex += segment.optional ? '/?' : '/'; - regex += segment.regex(); - } + for (var j = 0, jj = skippableStates.length; j < jj; j++) { + skippableStates[j].nextStates.push(firstState); + } - if (isAllOptional) { - if (isEmpty) { - currentState = currentState.put({ validChars: '/' }); - regex += '/'; + if (segment.optional) { + skippableStates.push(nextState); + regex += '(?:/' + segment.regex() + ')?'; } else { - var finalState = this.rootState.put({ validChars: '/' }); - currentState.epsilon = [finalState]; - currentState = finalState; + currentState = nextState; + regex += '/' + segment.regex(); + skippableStates.length = 0; + isEmpty = false; } } + if (isEmpty) { + currentState = currentState.put({ validChars: '/' }); + regex += '/?'; + } + var handlers = [{ handler: route.handler, names: names }]; if (routeName) { @@ -245,6 +250,13 @@ var RouteRecognizer = exports.RouteRecognizer = function () { } } + for (var _i3 = 0; _i3 < skippableStates.length; _i3++) { + var state = skippableStates[_i3]; + state.handlers = handlers; + state.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i'); + state.types = types; + } + currentState.handlers = handlers; currentState.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i'); currentState.types = types; @@ -346,9 +358,9 @@ var RouteRecognizer = exports.RouteRecognizer = function () { } var solutions = []; - for (var _i3 = 0, _l = states.length; _i3 < _l; _i3++) { - if (states[_i3].handlers) { - solutions.push(states[_i3]); + for (var _i4 = 0, _l = states.length; _i4 < _l; _i4++) { + if (states[_i4].handlers) { + solutions.push(states[_i4]); } } @@ -455,25 +467,6 @@ function recognizeChar(states, ch) { nextStates.push.apply(nextStates, state.match(ch)); } - var skippableStates = nextStates.filter(function (s) { - return s.epsilon; - }); - - var _loop = function _loop() { - var newStates = []; - skippableStates.forEach(function (s) { - nextStates.push.apply(nextStates, s.epsilon); - newStates.push.apply(newStates, s.epsilon); - }); - skippableStates = newStates.filter(function (s) { - return s.epsilon; - }); - }; - - while (skippableStates.length > 0) { - _loop(); - } - return nextStates; } @@ -500,15 +493,11 @@ function findHandler(state, path, queryParams) { } function addSegment(currentState, segment) { - var state = currentState.put({ validChars: '/' }); + var firstState = currentState.put({ validChars: '/' }); + var nextState = firstState; segment.eachChar(function (ch) { - state = state.put(ch); + nextState = nextState.put(ch); }); - if (segment.optional) { - currentState.epsilon = currentState.epsilon || []; - currentState.epsilon.push(state); - } - - return state; + return [firstState, nextState]; } \ No newline at end of file diff --git a/dist/es2015/aurelia-route-recognizer.js b/dist/es2015/aurelia-route-recognizer.js index a280743..6a16894 100644 --- a/dist/es2015/aurelia-route-recognizer.js +++ b/dist/es2015/aurelia-route-recognizer.js @@ -97,7 +97,7 @@ export let DynamicSegment = class DynamicSegment { } regex() { - return this.optional ? '([^/]+)?' : '([^/]+)'; + return '([^/]+)'; } generate(params, consumed) { @@ -150,12 +150,12 @@ export let RouteRecognizer = class RouteRecognizer { } let currentState = this.rootState; + let skippableStates = []; let regex = '^'; let types = { statics: 0, dynamics: 0, stars: 0 }; let names = []; let routeName = route.handler.name; let isEmpty = true; - let isAllOptional = true; let segments = parse(route.path, names, types, route.caseSensitive); for (let i = 0, ii = segments.length; i < ii; i++) { @@ -164,25 +164,28 @@ export let RouteRecognizer = class RouteRecognizer { continue; } - isEmpty = false; - isAllOptional = isAllOptional && segment.optional; + let [firstState, nextState] = addSegment(currentState, segment); - currentState = addSegment(currentState, segment); - regex += segment.optional ? '/?' : '/'; - regex += segment.regex(); - } + for (let j = 0, jj = skippableStates.length; j < jj; j++) { + skippableStates[j].nextStates.push(firstState); + } - if (isAllOptional) { - if (isEmpty) { - currentState = currentState.put({ validChars: '/' }); - regex += '/'; + if (segment.optional) { + skippableStates.push(nextState); + regex += `(?:/${segment.regex()})?`; } else { - let finalState = this.rootState.put({ validChars: '/' }); - currentState.epsilon = [finalState]; - currentState = finalState; + currentState = nextState; + regex += `/${segment.regex()}`; + skippableStates.length = 0; + isEmpty = false; } } + if (isEmpty) { + currentState = currentState.put({ validChars: '/' }); + regex += '/?'; + } + let handlers = [{ handler: route.handler, names: names }]; if (routeName) { @@ -195,6 +198,13 @@ export let RouteRecognizer = class RouteRecognizer { } } + for (let i = 0; i < skippableStates.length; i++) { + let state = skippableStates[i]; + state.handlers = handlers; + state.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i'); + state.types = types; + } + currentState.handlers = handlers; currentState.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i'); currentState.types = types; @@ -401,16 +411,6 @@ function recognizeChar(states, ch) { nextStates.push(...state.match(ch)); } - let skippableStates = nextStates.filter(s => s.epsilon); - while (skippableStates.length > 0) { - let newStates = []; - skippableStates.forEach(s => { - nextStates.push(...s.epsilon); - newStates.push(...s.epsilon); - }); - skippableStates = newStates.filter(s => s.epsilon); - } - return nextStates; } @@ -437,15 +437,11 @@ function findHandler(state, path, queryParams) { } function addSegment(currentState, segment) { - let state = currentState.put({ validChars: '/' }); + let firstState = currentState.put({ validChars: '/' }); + let nextState = firstState; segment.eachChar(ch => { - state = state.put(ch); + nextState = nextState.put(ch); }); - if (segment.optional) { - currentState.epsilon = currentState.epsilon || []; - currentState.epsilon.push(state); - } - - return state; + return [firstState, nextState]; } \ No newline at end of file diff --git a/dist/native-modules/aurelia-route-recognizer.js b/dist/native-modules/aurelia-route-recognizer.js index ba116d7..44f7070 100644 --- a/dist/native-modules/aurelia-route-recognizer.js +++ b/dist/native-modules/aurelia-route-recognizer.js @@ -122,7 +122,7 @@ export var DynamicSegment = function () { }; DynamicSegment.prototype.regex = function regex() { - return this.optional ? '([^/]+)?' : '([^/]+)'; + return '([^/]+)'; }; DynamicSegment.prototype.generate = function generate(params, consumed) { @@ -193,12 +193,12 @@ export var RouteRecognizer = function () { } var currentState = this.rootState; + var skippableStates = []; var regex = '^'; var types = { statics: 0, dynamics: 0, stars: 0 }; var names = []; var routeName = route.handler.name; var isEmpty = true; - var isAllOptional = true; var segments = parse(route.path, names, types, route.caseSensitive); for (var i = 0, ii = segments.length; i < ii; i++) { @@ -207,25 +207,30 @@ export var RouteRecognizer = function () { continue; } - isEmpty = false; - isAllOptional = isAllOptional && segment.optional; + var _addSegment = addSegment(currentState, segment), + firstState = _addSegment[0], + nextState = _addSegment[1]; - currentState = addSegment(currentState, segment); - regex += segment.optional ? '/?' : '/'; - regex += segment.regex(); - } + for (var j = 0, jj = skippableStates.length; j < jj; j++) { + skippableStates[j].nextStates.push(firstState); + } - if (isAllOptional) { - if (isEmpty) { - currentState = currentState.put({ validChars: '/' }); - regex += '/'; + if (segment.optional) { + skippableStates.push(nextState); + regex += '(?:/' + segment.regex() + ')?'; } else { - var finalState = this.rootState.put({ validChars: '/' }); - currentState.epsilon = [finalState]; - currentState = finalState; + currentState = nextState; + regex += '/' + segment.regex(); + skippableStates.length = 0; + isEmpty = false; } } + if (isEmpty) { + currentState = currentState.put({ validChars: '/' }); + regex += '/?'; + } + var handlers = [{ handler: route.handler, names: names }]; if (routeName) { @@ -238,6 +243,13 @@ export var RouteRecognizer = function () { } } + for (var _i3 = 0; _i3 < skippableStates.length; _i3++) { + var state = skippableStates[_i3]; + state.handlers = handlers; + state.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i'); + state.types = types; + } + currentState.handlers = handlers; currentState.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i'); currentState.types = types; @@ -339,9 +351,9 @@ export var RouteRecognizer = function () { } var solutions = []; - for (var _i3 = 0, _l = states.length; _i3 < _l; _i3++) { - if (states[_i3].handlers) { - solutions.push(states[_i3]); + for (var _i4 = 0, _l = states.length; _i4 < _l; _i4++) { + if (states[_i4].handlers) { + solutions.push(states[_i4]); } } @@ -448,25 +460,6 @@ function recognizeChar(states, ch) { nextStates.push.apply(nextStates, state.match(ch)); } - var skippableStates = nextStates.filter(function (s) { - return s.epsilon; - }); - - var _loop = function _loop() { - var newStates = []; - skippableStates.forEach(function (s) { - nextStates.push.apply(nextStates, s.epsilon); - newStates.push.apply(newStates, s.epsilon); - }); - skippableStates = newStates.filter(function (s) { - return s.epsilon; - }); - }; - - while (skippableStates.length > 0) { - _loop(); - } - return nextStates; } @@ -493,15 +486,11 @@ function findHandler(state, path, queryParams) { } function addSegment(currentState, segment) { - var state = currentState.put({ validChars: '/' }); + var firstState = currentState.put({ validChars: '/' }); + var nextState = firstState; segment.eachChar(function (ch) { - state = state.put(ch); + nextState = nextState.put(ch); }); - if (segment.optional) { - currentState.epsilon = currentState.epsilon || []; - currentState.epsilon.push(state); - } - - return state; + return [firstState, nextState]; } \ No newline at end of file diff --git a/dist/system/aurelia-route-recognizer.js b/dist/system/aurelia-route-recognizer.js index 1b3e76d..8f386d9 100644 --- a/dist/system/aurelia-route-recognizer.js +++ b/dist/system/aurelia-route-recognizer.js @@ -85,25 +85,6 @@ System.register(['aurelia-path'], function (_export, _context) { nextStates.push.apply(nextStates, state.match(ch)); } - var skippableStates = nextStates.filter(function (s) { - return s.epsilon; - }); - - var _loop = function _loop() { - var newStates = []; - skippableStates.forEach(function (s) { - nextStates.push.apply(nextStates, s.epsilon); - newStates.push.apply(newStates, s.epsilon); - }); - skippableStates = newStates.filter(function (s) { - return s.epsilon; - }); - }; - - while (skippableStates.length > 0) { - _loop(); - } - return nextStates; } @@ -130,17 +111,13 @@ System.register(['aurelia-path'], function (_export, _context) { } function addSegment(currentState, segment) { - var state = currentState.put({ validChars: '/' }); + var firstState = currentState.put({ validChars: '/' }); + var nextState = firstState; segment.eachChar(function (ch) { - state = state.put(ch); + nextState = nextState.put(ch); }); - if (segment.optional) { - currentState.epsilon = currentState.epsilon || []; - currentState.epsilon.push(state); - } - - return state; + return [firstState, nextState]; } return { setters: [function (_aureliaPath) { @@ -271,7 +248,7 @@ System.register(['aurelia-path'], function (_export, _context) { }; DynamicSegment.prototype.regex = function regex() { - return this.optional ? '([^/]+)?' : '([^/]+)'; + return '([^/]+)'; }; DynamicSegment.prototype.generate = function generate(params, consumed) { @@ -348,12 +325,12 @@ System.register(['aurelia-path'], function (_export, _context) { } var currentState = this.rootState; + var skippableStates = []; var regex = '^'; var types = { statics: 0, dynamics: 0, stars: 0 }; var names = []; var routeName = route.handler.name; var isEmpty = true; - var isAllOptional = true; var segments = parse(route.path, names, types, route.caseSensitive); for (var i = 0, ii = segments.length; i < ii; i++) { @@ -362,25 +339,30 @@ System.register(['aurelia-path'], function (_export, _context) { continue; } - isEmpty = false; - isAllOptional = isAllOptional && segment.optional; + var _addSegment = addSegment(currentState, segment), + firstState = _addSegment[0], + nextState = _addSegment[1]; - currentState = addSegment(currentState, segment); - regex += segment.optional ? '/?' : '/'; - regex += segment.regex(); - } + for (var j = 0, jj = skippableStates.length; j < jj; j++) { + skippableStates[j].nextStates.push(firstState); + } - if (isAllOptional) { - if (isEmpty) { - currentState = currentState.put({ validChars: '/' }); - regex += '/'; + if (segment.optional) { + skippableStates.push(nextState); + regex += '(?:/' + segment.regex() + ')?'; } else { - var finalState = this.rootState.put({ validChars: '/' }); - currentState.epsilon = [finalState]; - currentState = finalState; + currentState = nextState; + regex += '/' + segment.regex(); + skippableStates.length = 0; + isEmpty = false; } } + if (isEmpty) { + currentState = currentState.put({ validChars: '/' }); + regex += '/?'; + } + var handlers = [{ handler: route.handler, names: names }]; if (routeName) { @@ -393,6 +375,13 @@ System.register(['aurelia-path'], function (_export, _context) { } } + for (var _i3 = 0; _i3 < skippableStates.length; _i3++) { + var state = skippableStates[_i3]; + state.handlers = handlers; + state.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i'); + state.types = types; + } + currentState.handlers = handlers; currentState.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i'); currentState.types = types; @@ -494,9 +483,9 @@ System.register(['aurelia-path'], function (_export, _context) { } var solutions = []; - for (var _i3 = 0, _l = states.length; _i3 < _l; _i3++) { - if (states[_i3].handlers) { - solutions.push(states[_i3]); + for (var _i4 = 0, _l = states.length; _i4 < _l; _i4++) { + if (states[_i4].handlers) { + solutions.push(states[_i4]); } } diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index ef1e030..6752b6e 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,13 @@ + +# [1.2.0](https://github.com/aurelia/route-recognizer/compare/1.1.1...1.2.0) (2018-06-14) + + +### Bug Fixes + +* Require leading slashes to optional segments ([27f72a5](https://github.com/aurelia/route-recognizer/commit/27f72a5)) + + + ## [1.1.1](https://github.com/aurelia/route-recognizer/compare/1.1.0...1.1.1) (2017-10-01) diff --git a/doc/api.json b/doc/api.json index b4ebbcb..ba9097e 100644 --- a/doc/api.json +++ b/doc/api.json @@ -1 +1 @@ -{"name":"aurelia-route-recognizer","children":[{"id":47,"name":"DynamicSegment","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":48,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":49,"name":"new DynamicSegment","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":50,"name":"name","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"string"}},{"id":51,"name":"optional","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"boolean"}}],"type":{"type":"reference","name":"DynamicSegment","id":47}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":75,"character":37}]},{"id":52,"name":"eachChar","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":53,"name":"eachChar","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":54,"name":"callback","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":55,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":56,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":57,"name":"spec","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"CharSpec","id":15}}],"type":{"type":"intrinsic","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":77,"character":20}]}}}],"type":{"type":"intrinsic","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":77,"character":10}]},{"id":60,"name":"generate","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":61,"name":"generate","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":62,"name":"params","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Object"}},{"id":63,"name":"consumed","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Object"}}],"type":{"type":"intrinsic","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":79,"character":10}]},{"id":58,"name":"regex","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":59,"name":"regex","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"intrinsic","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":78,"character":7}]}],"groups":[{"title":"Constructors","kind":512,"children":[48]},{"title":"Methods","kind":2048,"children":[52,60,58]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":75,"character":35}]},{"id":80,"name":"EpsilonSegment","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":81,"name":"eachChar","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":82,"name":"eachChar","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"intrinsic","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":88,"character":10}]},{"id":85,"name":"generate","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":86,"name":"generate","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"intrinsic","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":90,"character":10}]},{"id":83,"name":"regex","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":84,"name":"regex","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"intrinsic","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":89,"character":7}]}],"groups":[{"title":"Methods","kind":2048,"children":[81,85,83]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":87,"character":35}]},{"id":87,"name":"RouteRecognizer","kind":128,"kindString":"Class","flags":{"isExported":true},"comment":{"shortText":"Class that parses route patterns and matches path strings.","tags":[{"tag":"class","text":"RouteRecognizer"},{"tag":"constructor","text":"\n"}]},"children":[{"id":88,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":89,"name":"new RouteRecognizer","kind":16384,"kindString":"Constructor signature","flags":{},"type":{"type":"reference","name":"RouteRecognizer","id":87}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":105,"character":38}]},{"id":90,"name":"add","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":91,"name":"add","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Parse a route pattern and add it to the collection of recognized routes."},"parameters":[{"id":92,"name":"route","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The route to add.\n"},"type":{"type":"union","types":[{"type":"reference","name":"ConfigurableRoute","id":4},{"type":"array","elementType":{"type":"reference","name":"ConfigurableRoute","id":4}}]}}],"type":{"type":"reference","name":"State","id":19}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":113,"character":5}]},{"id":99,"name":"generate","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":100,"name":"generate","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Generate a path and query string from a route name and params object.","returns":"The generated absolute path and query string.\n"},"parameters":[{"id":101,"name":"name","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The name of the route."},"type":{"type":"intrinsic","name":"string"}},{"id":102,"name":"params","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The route params to use when populating the pattern.\n Properties not required by the pattern will be appended to the query string."},"type":{"type":"reference","name":"Object"}}],"type":{"type":"intrinsic","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":139,"character":10}]},{"id":93,"name":"handlersFor","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":94,"name":"handlersFor","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Retrieve the handlers registered for the named route.","returns":"The handlers.\n"},"parameters":[{"id":95,"name":"name","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The name of the route."},"type":{"type":"intrinsic","name":"string"}}],"type":{"type":"array","elementType":{"type":"reference","name":"HandlerEntry","id":8}}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":121,"character":13}]},{"id":96,"name":"hasRoute","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":97,"name":"hasRoute","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Check if this RouteRecognizer recognizes a named route.","returns":"True if the named route is recognized.\n"},"parameters":[{"id":98,"name":"name","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The name of the route."},"type":{"type":"intrinsic","name":"string"}}],"type":{"type":"intrinsic","name":"boolean"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":129,"character":10}]},{"id":103,"name":"recognize","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":104,"name":"recognize","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Match a path string against registered route patterns.","returns":"Array of objects containing `handler`, `params`, and\n `isDynanic` values for the matched route(s), or undefined if no match\n was found.\n"},"parameters":[{"id":105,"name":"path","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The path to attempt to match."},"type":{"type":"intrinsic","name":"string"}}],"type":{"type":"union","types":[{"type":"array","elementType":{"type":"reference","name":"RecognizedRoute","id":11}},{"type":"intrinsic","name":"undefined"}]}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":149,"character":11}]}],"groups":[{"title":"Constructors","kind":512,"children":[88]},{"title":"Methods","kind":2048,"children":[90,99,93,96,103]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":105,"character":36}]},{"id":64,"name":"StarSegment","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":65,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":66,"name":"new StarSegment","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":67,"name":"name","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"string"}}],"type":{"type":"reference","name":"StarSegment","id":64}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":81,"character":34}]},{"id":68,"name":"eachChar","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":69,"name":"eachChar","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":70,"name":"callback","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":71,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":72,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":73,"name":"spec","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"CharSpec","id":15}}],"type":{"type":"intrinsic","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":83,"character":20}]}}}],"type":{"type":"intrinsic","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":83,"character":10}]},{"id":76,"name":"generate","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":77,"name":"generate","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":78,"name":"params","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Object"}},{"id":79,"name":"consumed","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Object"}}],"type":{"type":"intrinsic","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":85,"character":10}]},{"id":74,"name":"regex","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":75,"name":"regex","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"intrinsic","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":84,"character":7}]}],"groups":[{"title":"Constructors","kind":512,"children":[65]},{"title":"Methods","kind":2048,"children":[68,76,74]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":81,"character":32}]},{"id":19,"name":"State","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":20,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":21,"name":"new State","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":22,"name":"charSpec","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"CharSpec","id":15}}],"type":{"type":"reference","name":"State","id":19}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":44,"character":28}]},{"id":23,"name":"get","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":24,"name":"get","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":25,"name":"charSpec","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"CharSpec","id":15}}],"type":{"type":"reference","name":"State","id":19}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":46,"character":5}]},{"id":29,"name":"match","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":30,"name":"match","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":31,"name":"ch","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"string"}}],"type":{"type":"array","elementType":{"type":"reference","name":"State","id":19}}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":50,"character":7}]},{"id":26,"name":"put","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":27,"name":"put","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":28,"name":"charSpec","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"CharSpec","id":15}}],"type":{"type":"reference","name":"State","id":19}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":47,"character":5}]}],"groups":[{"title":"Constructors","kind":512,"children":[20]},{"title":"Methods","kind":2048,"children":[23,29,26]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":44,"character":26}]},{"id":32,"name":"StaticSegment","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":33,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":34,"name":"new StaticSegment","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":35,"name":"string","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"string"}},{"id":36,"name":"caseSensitive","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"boolean"}}],"type":{"type":"reference","name":"StaticSegment","id":32}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":69,"character":36}]},{"id":37,"name":"eachChar","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":38,"name":"eachChar","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":39,"name":"callback","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":40,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":41,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":42,"name":"spec","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"CharSpec","id":15}}],"type":{"type":"intrinsic","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":71,"character":20}]}}}],"type":{"type":"intrinsic","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":71,"character":10}]},{"id":45,"name":"generate","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":46,"name":"generate","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"intrinsic","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":73,"character":10}]},{"id":43,"name":"regex","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":44,"name":"regex","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"intrinsic","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":72,"character":7}]}],"groups":[{"title":"Constructors","kind":512,"children":[33]},{"title":"Methods","kind":2048,"children":[37,45,43]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":69,"character":34}]},{"id":15,"name":"CharSpec","kind":256,"kindString":"Interface","flags":{"isExported":true},"children":[{"id":16,"name":"invalidChars","kind":1024,"kindString":"Property","flags":{"isExported":true,"isOptional":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":23,"character":14}],"type":{"type":"intrinsic","name":"string"}},{"id":18,"name":"repeat","kind":1024,"kindString":"Property","flags":{"isExported":true,"isOptional":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":25,"character":8}],"type":{"type":"intrinsic","name":"boolean"}},{"id":17,"name":"validChars","kind":1024,"kindString":"Property","flags":{"isExported":true,"isOptional":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":24,"character":12}],"type":{"type":"intrinsic","name":"string"}}],"groups":[{"title":"Properties","kind":1024,"children":[16,18,17]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":22,"character":33}]},{"id":4,"name":"ConfigurableRoute","kind":256,"kindString":"Interface","flags":{"isExported":true},"children":[{"id":7,"name":"caseSensitive","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":11,"character":15}],"type":{"type":"intrinsic","name":"boolean"}},{"id":6,"name":"handler","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":10,"character":9}],"type":{"type":"reference","name":"RouteHandler","id":2}},{"id":5,"name":"path","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":9,"character":6}],"type":{"type":"intrinsic","name":"string"}}],"groups":[{"title":"Properties","kind":1024,"children":[7,6,5]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":8,"character":42}]},{"id":8,"name":"HandlerEntry","kind":256,"kindString":"Interface","flags":{"isExported":true},"children":[{"id":9,"name":"handler","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":14,"character":9}],"type":{"type":"reference","name":"RouteHandler","id":2}},{"id":10,"name":"names","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":15,"character":7}],"type":{"type":"array","elementType":{"type":"intrinsic","name":"string"}}}],"groups":[{"title":"Properties","kind":1024,"children":[9,10]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":13,"character":37}]},{"id":11,"name":"RecognizedRoute","kind":256,"kindString":"Interface","flags":{"isExported":true},"children":[{"id":12,"name":"handler","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":18,"character":9}],"type":{"type":"reference","name":"RouteHandler","id":2}},{"id":14,"name":"isDynamic","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":20,"character":11}],"type":{"type":"intrinsic","name":"boolean"}},{"id":13,"name":"params","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":19,"character":8}],"type":{"type":"reference","name":"Object"}}],"groups":[{"title":"Properties","kind":1024,"children":[12,14,13]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":17,"character":40}]},{"id":2,"name":"RouteHandler","kind":256,"kindString":"Interface","flags":{"isExported":true},"children":[{"id":3,"name":"name","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":6,"character":6}],"type":{"type":"intrinsic","name":"string"}}],"groups":[{"title":"Properties","kind":1024,"children":[3]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":5,"character":37}]}],"groups":[{"title":"Classes","kind":128,"children":[47,80,87,64,19,32]},{"title":"Interfaces","kind":256,"children":[15,4,8,11,2]}]} \ No newline at end of file +{"name":"aurelia-route-recognizer","children":[{"id":47,"name":"DynamicSegment","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":48,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":49,"name":"new DynamicSegment","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":50,"name":"name","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"string"}},{"id":51,"name":"optional","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"boolean"}}],"type":{"type":"reference","name":"DynamicSegment","id":47}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":75,"character":37}]},{"id":52,"name":"eachChar","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":53,"name":"eachChar","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":54,"name":"callback","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":55,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":56,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":57,"name":"spec","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"CharSpec","id":15}}],"type":{"type":"instrinct","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":77,"character":20}]}}}],"type":{"type":"instrinct","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":77,"character":10}]},{"id":60,"name":"generate","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":61,"name":"generate","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":62,"name":"params","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Object"}},{"id":63,"name":"consumed","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Object"}}],"type":{"type":"instrinct","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":79,"character":10}]},{"id":58,"name":"regex","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":59,"name":"regex","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":78,"character":7}]}],"groups":[{"title":"Constructors","kind":512,"children":[48]},{"title":"Methods","kind":2048,"children":[52,60,58]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":75,"character":35}]},{"id":80,"name":"EpsilonSegment","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":81,"name":"eachChar","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":82,"name":"eachChar","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":88,"character":10}]},{"id":85,"name":"generate","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":86,"name":"generate","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":90,"character":10}]},{"id":83,"name":"regex","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":84,"name":"regex","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":89,"character":7}]}],"groups":[{"title":"Methods","kind":2048,"children":[81,85,83]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":87,"character":35}]},{"id":87,"name":"RouteRecognizer","kind":128,"kindString":"Class","flags":{"isExported":true},"comment":{"shortText":"Class that parses route patterns and matches path strings.","tags":[{"tag":"class","text":"RouteRecognizer"},{"tag":"constructor","text":"\n"}]},"children":[{"id":88,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":89,"name":"new RouteRecognizer","kind":16384,"kindString":"Constructor signature","flags":{},"type":{"type":"reference","name":"RouteRecognizer","id":87}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":105,"character":38}]},{"id":90,"name":"add","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":91,"name":"add","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Parse a route pattern and add it to the collection of recognized routes."},"parameters":[{"id":92,"name":"route","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The route to add.\n"},"type":{"type":"union","types":[{"type":"reference","name":"ConfigurableRoute","id":4},{"type":"reference","isArray":true,"name":"ConfigurableRoute","id":4}]}}],"type":{"type":"reference","name":"State","id":19}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":113,"character":5}]},{"id":99,"name":"generate","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":100,"name":"generate","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Generate a path and query string from a route name and params object.","returns":"The generated absolute path and query string.\n"},"parameters":[{"id":101,"name":"name","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The name of the route."},"type":{"type":"instrinct","name":"string"}},{"id":102,"name":"params","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The route params to use when populating the pattern.\n Properties not required by the pattern will be appended to the query string."},"type":{"type":"reference","name":"Object"}}],"type":{"type":"instrinct","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":139,"character":10}]},{"id":93,"name":"handlersFor","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":94,"name":"handlersFor","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Retrieve the handlers registered for the named route.","returns":"The handlers.\n"},"parameters":[{"id":95,"name":"name","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The name of the route."},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","isArray":true,"name":"HandlerEntry","id":8}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":121,"character":13}]},{"id":96,"name":"hasRoute","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":97,"name":"hasRoute","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Check if this RouteRecognizer recognizes a named route.","returns":"True if the named route is recognized.\n"},"parameters":[{"id":98,"name":"name","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The name of the route."},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"instrinct","name":"boolean"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":129,"character":10}]},{"id":103,"name":"recognize","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":104,"name":"recognize","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Match a path string against registered route patterns.","returns":"Array of objects containing `handler`, `params`, and\n `isDynanic` values for the matched route(s), or undefined if no match\n was found.\n"},"parameters":[{"id":105,"name":"path","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The path to attempt to match."},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"union","types":[{"type":"reference","isArray":true,"name":"RecognizedRoute","id":11},{"type":"instrinct","name":"void"}]}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":149,"character":11}]}],"groups":[{"title":"Constructors","kind":512,"children":[88]},{"title":"Methods","kind":2048,"children":[90,99,93,96,103]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":105,"character":36}]},{"id":64,"name":"StarSegment","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":65,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":66,"name":"new StarSegment","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":67,"name":"name","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","name":"StarSegment","id":64}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":81,"character":34}]},{"id":68,"name":"eachChar","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":69,"name":"eachChar","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":70,"name":"callback","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":71,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":72,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":73,"name":"spec","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"CharSpec","id":15}}],"type":{"type":"instrinct","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":83,"character":20}]}}}],"type":{"type":"instrinct","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":83,"character":10}]},{"id":76,"name":"generate","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":77,"name":"generate","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":78,"name":"params","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Object"}},{"id":79,"name":"consumed","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Object"}}],"type":{"type":"instrinct","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":85,"character":10}]},{"id":74,"name":"regex","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":75,"name":"regex","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":84,"character":7}]}],"groups":[{"title":"Constructors","kind":512,"children":[65]},{"title":"Methods","kind":2048,"children":[68,76,74]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":81,"character":32}]},{"id":19,"name":"State","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":20,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":21,"name":"new State","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":22,"name":"charSpec","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"CharSpec","id":15}}],"type":{"type":"reference","name":"State","id":19}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":44,"character":28}]},{"id":23,"name":"get","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":24,"name":"get","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":25,"name":"charSpec","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"CharSpec","id":15}}],"type":{"type":"reference","name":"State","id":19}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":46,"character":5}]},{"id":29,"name":"match","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":30,"name":"match","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":31,"name":"ch","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","isArray":true,"name":"State","id":19}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":50,"character":7}]},{"id":26,"name":"put","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":27,"name":"put","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":28,"name":"charSpec","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"CharSpec","id":15}}],"type":{"type":"reference","name":"State","id":19}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":47,"character":5}]}],"groups":[{"title":"Constructors","kind":512,"children":[20]},{"title":"Methods","kind":2048,"children":[23,29,26]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":44,"character":26}]},{"id":32,"name":"StaticSegment","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":33,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":34,"name":"new StaticSegment","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":35,"name":"string","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"string"}},{"id":36,"name":"caseSensitive","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"boolean"}}],"type":{"type":"reference","name":"StaticSegment","id":32}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":69,"character":36}]},{"id":37,"name":"eachChar","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":38,"name":"eachChar","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":39,"name":"callback","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reflection","declaration":{"id":40,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"signatures":[{"id":41,"name":"__call","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":42,"name":"spec","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"CharSpec","id":15}}],"type":{"type":"instrinct","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":71,"character":20}]}}}],"type":{"type":"instrinct","name":"void"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":71,"character":10}]},{"id":45,"name":"generate","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":46,"name":"generate","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":73,"character":10}]},{"id":43,"name":"regex","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":44,"name":"regex","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"string"}}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":72,"character":7}]}],"groups":[{"title":"Constructors","kind":512,"children":[33]},{"title":"Methods","kind":2048,"children":[37,45,43]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":69,"character":34}]},{"id":15,"name":"CharSpec","kind":256,"kindString":"Interface","flags":{"isExported":true},"children":[{"id":16,"name":"invalidChars","kind":1024,"kindString":"Property","flags":{"isExported":true,"isOptional":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":23,"character":14}],"type":{"type":"instrinct","name":"string"}},{"id":18,"name":"repeat","kind":1024,"kindString":"Property","flags":{"isExported":true,"isOptional":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":25,"character":8}],"type":{"type":"instrinct","name":"boolean"}},{"id":17,"name":"validChars","kind":1024,"kindString":"Property","flags":{"isExported":true,"isOptional":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":24,"character":12}],"type":{"type":"instrinct","name":"string"}}],"groups":[{"title":"Properties","kind":1024,"children":[16,18,17]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":22,"character":33}]},{"id":4,"name":"ConfigurableRoute","kind":256,"kindString":"Interface","flags":{"isExported":true},"children":[{"id":7,"name":"caseSensitive","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":11,"character":15}],"type":{"type":"instrinct","name":"boolean"}},{"id":6,"name":"handler","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":10,"character":9}],"type":{"type":"reference","name":"RouteHandler","id":2}},{"id":5,"name":"path","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":9,"character":6}],"type":{"type":"instrinct","name":"string"}}],"groups":[{"title":"Properties","kind":1024,"children":[7,6,5]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":8,"character":42}]},{"id":8,"name":"HandlerEntry","kind":256,"kindString":"Interface","flags":{"isExported":true},"children":[{"id":9,"name":"handler","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":14,"character":9}],"type":{"type":"reference","name":"RouteHandler","id":2}},{"id":10,"name":"names","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":15,"character":7}],"type":{"type":"instrinct","isArray":true,"name":"string"}}],"groups":[{"title":"Properties","kind":1024,"children":[9,10]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":13,"character":37}]},{"id":11,"name":"RecognizedRoute","kind":256,"kindString":"Interface","flags":{"isExported":true},"children":[{"id":12,"name":"handler","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":18,"character":9}],"type":{"type":"reference","name":"RouteHandler","id":2}},{"id":14,"name":"isDynamic","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":20,"character":11}],"type":{"type":"instrinct","name":"boolean"}},{"id":13,"name":"params","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":19,"character":8}],"type":{"type":"reference","name":"Object"}}],"groups":[{"title":"Properties","kind":1024,"children":[12,14,13]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":17,"character":40}]},{"id":2,"name":"RouteHandler","kind":256,"kindString":"Interface","flags":{"isExported":true},"children":[{"id":3,"name":"name","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":6,"character":6}],"type":{"type":"instrinct","name":"string"}}],"groups":[{"title":"Properties","kind":1024,"children":[3]}],"sources":[{"fileName":"aurelia-route-recognizer.d.ts","line":5,"character":37}]}],"groups":[{"title":"Classes","kind":128,"children":[47,80,87,64,19,32]},{"title":"Interfaces","kind":256,"children":[15,4,8,11,2]}]} \ No newline at end of file diff --git a/package.json b/package.json index 286e9a8..a28158e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-route-recognizer", - "version": "1.1.1", + "version": "1.2.0", "description": "A lightweight JavaScript library that matches paths against registered routes. It includes support for dynamic and star segments and nested handlers.", "keywords": [ "aurelia",