fix(router): throw when reserved characters used in route definition

Closes #3021
This commit is contained in:
Brian Ford
2015-07-17 02:01:34 -07:00
parent 573c047d50
commit c6409cb624
2 changed files with 31 additions and 0 deletions
@@ -21,6 +21,24 @@ var mockRouteHandler = new SyncRouteHandler(DummyClass);
export function main() {
describe('PathRecognizer', () => {
it('should throw when given an invalid path', () => {
expect(() => new PathRecognizer('/hi#', mockRouteHandler))
.toThrowError(`Path "/hi#" should not include "#". Use "HashLocationStrategy" instead.`);
expect(() => new PathRecognizer('hi?', mockRouteHandler))
.toThrowError(`Path "hi?" contains "?" which is not allowed in a route config.`);
expect(() => new PathRecognizer('hi;', mockRouteHandler))
.toThrowError(`Path "hi;" contains ";" which is not allowed in a route config.`);
expect(() => new PathRecognizer('hi=', mockRouteHandler))
.toThrowError(`Path "hi=" contains "=" which is not allowed in a route config.`);
expect(() => new PathRecognizer('hi(', mockRouteHandler))
.toThrowError(`Path "hi(" contains "(" which is not allowed in a route config.`);
expect(() => new PathRecognizer('hi)', mockRouteHandler))
.toThrowError(`Path "hi)" contains ")" which is not allowed in a route config.`);
expect(() => new PathRecognizer('hi//there', mockRouteHandler))
.toThrowError(`Path "hi//there" contains "//" which is not allowed in a route config.`);
});
describe('matrix params', () => {
it('should recognize a trailing matrix value on a path value and assign it to the params return value',
() => {