Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aurelia-route-recognizer

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aurelia-route-recognizer - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

2

bower.json
{
"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.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -131,3 +131,3 @@ define(['exports', 'aurelia-path'], function (exports, _aureliaPath) {

DynamicSegment.prototype.regex = function regex() {
return this.optional ? '([^/]+)?' : '([^/]+)';
return '([^/]+)';
};

@@ -203,2 +203,3 @@

var currentState = this.rootState;
var skippableStates = [];
var regex = '^';

@@ -209,3 +210,2 @@ var types = { statics: 0, dynamics: 0, stars: 0 };

var isEmpty = true;
var isAllOptional = true;
var segments = parse(route.path, names, types, route.caseSensitive);

@@ -219,21 +219,26 @@

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 }];

@@ -251,2 +256,9 @@

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;

@@ -353,5 +365,5 @@ currentState.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i');

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]);
}

@@ -463,21 +475,2 @@ }

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;

@@ -509,14 +502,10 @@ }

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];
}
});

@@ -149,3 +149,3 @@ import {

*/
recognize(path: string): RecognizedRoute[] | undefined;
recognize(path: string): RecognizedRoute[] | void;
}

@@ -147,3 +147,3 @@ import {buildQueryString,parseQueryString} from 'aurelia-path';

regex(): string {
return this.optional ? '([^/]+)?' : '([^/]+)';
return '([^/]+)';
}

@@ -240,2 +240,3 @@

let currentState = this.rootState;
let skippableStates = [];
let regex = '^';

@@ -246,3 +247,2 @@ let types = { statics: 0, dynamics: 0, stars: 0 };

let isEmpty = true;
let isAllOptional = true;
let segments = parse(route.path, names, types, route.caseSensitive);

@@ -256,23 +256,34 @@

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);
if (isAllOptional) {
if (isEmpty) {
currentState = currentState.put({ validChars: '/' });
regex += '/';
// 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 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 }];

@@ -290,2 +301,11 @@

// 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;

@@ -388,3 +408,3 @@ currentState.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i');

*/
recognize(path: string): RecognizedRoute[] | undefined {
recognize(path: string): RecognizedRoute[] | void {
let states = [this.rootState];

@@ -542,12 +562,2 @@ let queryParams = {};

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;

@@ -579,13 +589,9 @@ }

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];
}

@@ -132,3 +132,3 @@ 'use strict';

DynamicSegment.prototype.regex = function regex() {
return this.optional ? '([^/]+)?' : '([^/]+)';
return '([^/]+)';
};

@@ -204,2 +204,3 @@

var currentState = this.rootState;
var skippableStates = [];
var regex = '^';

@@ -210,3 +211,2 @@ var types = { statics: 0, dynamics: 0, stars: 0 };

var isEmpty = true;
var isAllOptional = true;
var segments = parse(route.path, names, types, route.caseSensitive);

@@ -220,21 +220,26 @@

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 }];

@@ -252,2 +257,9 @@

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;

@@ -354,5 +366,5 @@ currentState.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i');

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]);
}

@@ -464,21 +476,2 @@ }

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;

@@ -510,13 +503,9 @@ }

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];
}

@@ -100,3 +100,3 @@ import { buildQueryString, parseQueryString } from 'aurelia-path';

regex() {
return this.optional ? '([^/]+)?' : '([^/]+)';
return '([^/]+)';
}

@@ -154,2 +154,3 @@

let currentState = this.rootState;
let skippableStates = [];
let regex = '^';

@@ -160,3 +161,2 @@ let types = { statics: 0, dynamics: 0, stars: 0 };

let isEmpty = true;
let isAllOptional = true;
let segments = parse(route.path, names, types, route.caseSensitive);

@@ -170,21 +170,24 @@

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 }];

@@ -202,2 +205,9 @@

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;

@@ -409,12 +419,2 @@ currentState.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i');

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;

@@ -446,13 +446,9 @@ }

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];
}

@@ -125,3 +125,3 @@

DynamicSegment.prototype.regex = function regex() {
return this.optional ? '([^/]+)?' : '([^/]+)';
return '([^/]+)';
};

@@ -197,2 +197,3 @@

var currentState = this.rootState;
var skippableStates = [];
var regex = '^';

@@ -203,3 +204,2 @@ var types = { statics: 0, dynamics: 0, stars: 0 };

var isEmpty = true;
var isAllOptional = true;
var segments = parse(route.path, names, types, route.caseSensitive);

@@ -213,21 +213,26 @@

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 }];

@@ -245,2 +250,9 @@

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;

@@ -347,5 +359,5 @@ currentState.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i');

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]);
}

@@ -457,21 +469,2 @@ }

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;

@@ -503,13 +496,9 @@ }

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];
}

@@ -88,21 +88,2 @@ 'use strict';

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;

@@ -134,13 +115,9 @@ }

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];
}

@@ -276,3 +253,3 @@ return {

DynamicSegment.prototype.regex = function regex() {
return this.optional ? '([^/]+)?' : '([^/]+)';
return '([^/]+)';
};

@@ -354,2 +331,3 @@

var currentState = this.rootState;
var skippableStates = [];
var regex = '^';

@@ -360,3 +338,2 @@ var types = { statics: 0, dynamics: 0, stars: 0 };

var isEmpty = true;
var isAllOptional = true;
var segments = parse(route.path, names, types, route.caseSensitive);

@@ -370,21 +347,26 @@

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 }];

@@ -402,2 +384,9 @@

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;

@@ -504,5 +493,5 @@ currentState.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i');

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]);
}

@@ -509,0 +498,0 @@ }

@@ -1,1 +0,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]}]}
{"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]}]}

@@ -0,1 +1,11 @@

<a name="1.2.0"></a>
# [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))
<a name="1.1.1"></a>

@@ -2,0 +12,0 @@ ## [1.1.1](https://github.com/aurelia/route-recognizer/compare/1.1.0...1.1.1) (2017-10-01)

{
"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.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -10,3 +10,3 @@ # aurelia-route-recognizer

> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.aurelia.io/) and [our email list](http://eepurl.com/ces50j). We also invite you to [follow us on twitter](https://twitter.com/aureliaeffect). If you have questions, please [join our community on Gitter](https://gitter.im/aurelia/discuss) or use [stack overflow](http://stackoverflow.com/search?q=aurelia). Documentation can be found [in our developer hub](http://aurelia.io/hub.html). If you would like to have deeper insight into our development process, please install the [ZenHub](https://zenhub.io) Chrome or Firefox Extension and visit any of our repository's boards.
> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.aurelia.io/) and [our email list](http://eepurl.com/ces50j). We also invite you to [follow us on twitter](https://twitter.com/aureliaeffect). If you have questions look around our [Discourse forums](https://discourse.aurelia.io/), chat in our [community on Gitter](https://gitter.im/aurelia/discuss) or use [stack overflow](http://stackoverflow.com/search?q=aurelia). Documentation can be found [in our developer hub](http://aurelia.io/docs). If you would like to have deeper insight into our development process, please install the [ZenHub](https://zenhub.io) Chrome or Firefox Extension and visit any of our repository's boards.

@@ -13,0 +13,0 @@ ## Platform Support

@@ -34,2 +34,3 @@ import {buildQueryString, parseQueryString} from 'aurelia-path';

let currentState = this.rootState;
let skippableStates = [];
let regex = '^';

@@ -40,3 +41,2 @@ let types = { statics: 0, dynamics: 0, stars: 0 };

let isEmpty = true;
let isAllOptional = true;
let segments = parse(route.path, names, types, route.caseSensitive);

@@ -50,23 +50,34 @@

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);
if (isAllOptional) {
if (isEmpty) {
currentState = currentState.put({ validChars: '/' });
regex += '/';
// 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 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 }];

@@ -84,2 +95,11 @@

// 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;

@@ -182,3 +202,3 @@ currentState.regex = new RegExp(regex + '$', route.caseSensitive ? '' : 'i');

*/
recognize(path: string): RecognizedRoute[] | undefined {
recognize(path: string): RecognizedRoute[] | void {
let states = [this.rootState];

@@ -336,12 +356,2 @@ let queryParams = {};

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;

@@ -373,13 +383,9 @@ }

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];
}

@@ -59,3 +59,3 @@ const specials = [

regex(): string {
return this.optional ? '([^/]+)?' : '([^/]+)';
return '([^/]+)';
}

@@ -62,0 +62,0 @@

import { RouteRecognizer } from '../src/route-recognizer';
import core from 'core-js';
const staticRoute = {'path': 'static','handler': {'name': 'static'}};
const dynamicRoute = {'path': 'dynamic/:id','handler': {'name': 'dynamic'}};
const multiNameRoute = {'path': 'static','handler': {'name': ['static-multiple', 'static-multiple-alias']}};
const staticRoute = {'path': 'static', 'handler': {'name': 'static'}};
const dynamicRoute = {'path': 'dynamic/:id', 'handler': {'name': 'dynamic'}};
const optionalRoute = {'path': 'optional/:id?', 'handler': {'name': 'optional'}};
const multiNameRoute = {'path': 'static', 'handler': {'name': ['static-multiple', 'static-multiple-alias']}};
const routeTestData = [{
title: 'empty path routes',
route: {'path': '','handler': {'name': 'static'}},
isDynamic: false,
path: '/',
params: {}
}, {
title: 'static routes',
route: staticRoute,
isDynamic: false,
path: '/static',
params: {}
}, {
title: 'dynamic routes',
route: dynamicRoute,
isDynamic: true,
path: '/dynamic/test',
params: { id: 'test' }
}, {
title: 'multi-segment dynamic routes',
route: { 'path': 'dynamic/:id/:other','handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/dynamic/foo/bar',
params: { id: 'foo', other: 'bar' }
}, {
title: 'duplicate dynamic routes',
route: { 'path': 'dynamic/:id/:id','handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/dynamic/foo/foo',
params: { id: 'foo' }
}, {
title: 'star routes',
route: { 'path': 'star/*path','handler': { 'name': 'star' }},
isDynamic: true,
path: '/star/test/path',
params: { path: 'test/path' }
}, {
title: 'dynamic star routes',
route: { 'path': 'dynamic/:id/star/*path','handler': { 'name': 'star' }},
isDynamic: true,
path: '/dynamic/foo/star/test/path',
params: { id: 'foo', path: 'test/path' }
}, {
title: 'optional parameter routes',
route: { 'path': 'param/:id?/edit', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/param/42/edit',
params: { id: '42' }
}, {
title: 'missing optional parameter routes',
route: { 'path': 'param/:id?/edit', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/param/edit',
params: { id: undefined }
}, {
title: 'multiple optional parameters routes',
route: { 'path': 'param/:x?/edit/:y?', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/param/edit/42',
params: { x: undefined, y: '42' }
}, {
title: 'ambiguous optional parameters routes',
route: { 'path': 'pt/:x?/:y?', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/pt/7',
params: { x: '7', y: undefined }
}, {
title: 'empty optional parameters routes',
route: { 'path': ':x?/:y?', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/',
params: { x: undefined, y: undefined }
}, {
title: 'almost empty optional parameter routes',
route: { 'path': ':x?', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/42',
params: { x: '42' }
}];
title: 'empty path routes',
route: {'path': '', 'handler': {'name': 'static'}},
isDynamic: false,
path: '/',
params: {}
}, {
title: 'static routes',
route: staticRoute,
isDynamic: false,
path: '/static',
params: {}
}, {
title: 'dynamic routes',
route: dynamicRoute,
isDynamic: true,
path: '/dynamic/test',
params: { id: 'test' }
}, {
title: 'multi-segment dynamic routes',
route: { 'path': 'dynamic/:id/:other', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/dynamic/foo/bar',
params: { id: 'foo', other: 'bar' }
}, {
title: 'duplicate dynamic routes',
route: { 'path': 'dynamic/:id/:id', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/dynamic/foo/foo',
params: { id: 'foo' }
}, {
title: 'star routes',
route: { 'path': 'star/*path', 'handler': { 'name': 'star' }},
isDynamic: true,
path: '/star/test/path',
params: { path: 'test/path' }
}, {
title: 'dynamic star routes',
route: { 'path': 'dynamic/:id/star/*path', 'handler': { 'name': 'star' }},
isDynamic: true,
path: '/dynamic/foo/star/test/path',
params: { id: 'foo', path: 'test/path' }
}, {
title: 'optional parameter routes',
route: { 'path': 'param/:id?/edit', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/param/42/edit',
params: { id: '42' }
}, {
title: 'missing optional parameter routes',
route: { 'path': 'param/:id?/edit', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/param/edit',
params: { id: undefined }
}, {
title: 'multiple optional parameters routes',
route: { 'path': 'param/:x?/edit/:y?', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/param/edit/42',
params: { x: undefined, y: '42' }
}, {
title: 'ambiguous optional parameters routes',
route: { 'path': 'pt/:x?/:y?', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/pt/7',
params: { x: '7', y: undefined }
}, {
title: 'empty optional parameters routes',
route: { 'path': ':x?/:y?', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/',
params: { x: undefined, y: undefined }
}, {
title: 'almost empty optional parameter routes',
route: { 'path': ':x?', 'handler': { 'name': 'dynamic' }},
isDynamic: true,
path: '/42',
params: { x: '42' }
}];

@@ -106,3 +107,3 @@ describe('route recognizer', () => {

let recognizer = new RouteRecognizer();
recognizer.add([{'path': 'b','handler': {}}]);
recognizer.add([{'path': 'b', 'handler': {}}]);

@@ -189,7 +190,17 @@ expect(recognizer.names).toEqual({});

expect(recognizer.handlersFor('static-multiple')[0].handler)
.toEqual(recognizer.handlersFor('static-multiple-alias')[0].handler)
.toEqual(recognizer.handlersFor('static-multiple-alias')[0].handler);
});
it(`can set case sensitive route and fails`, () => {
it('should distinguish between dynamic and static parts', () => {
let recognizer = new RouteRecognizer();
let similarRoute = { 'path': 'optionalToo/:id?', 'handler': { 'name': 'similar' }};
recognizer.add([optionalRoute, similarRoute]);
let result = recognizer.recognize('optionalToo');
expect(result.length).toEqual(1);
expect(result[0].handler.name).toEqual('similar');
});
it('can set case sensitive route and fails', () => {
let recognizer = new RouteRecognizer();
const routeTest = {

@@ -196,0 +207,0 @@ title: 'case sensitive route',

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc