fix(router): add ability to recover from malformed url (#23283)

Fixes #21468

PR Close #23283
This commit is contained in:
sergeome
2018-04-10 05:01:07 -05:00
committed by Miško Hevery
parent 505b54b86b
commit 86d254d386
5 changed files with 95 additions and 9 deletions

View File

@ -115,12 +115,20 @@ export function setupTestingRouter(
opts?: ExtraOptions | UrlHandlingStrategy, urlHandlingStrategy?: UrlHandlingStrategy) {
const router = new Router(
null !, urlSerializer, contexts, location, injector, loader, compiler, flatten(routes));
// Handle deprecated argument ordering.
if (opts) {
// Handle deprecated argument ordering.
if (isUrlHandlingStrategy(opts)) {
router.urlHandlingStrategy = opts;
} else if (opts.paramsInheritanceStrategy) {
router.paramsInheritanceStrategy = opts.paramsInheritanceStrategy;
} else {
// Handle ExtraOptions
if (opts.malformedUriErrorHandler) {
router.malformedUriErrorHandler = opts.malformedUriErrorHandler;
}
if (opts.paramsInheritanceStrategy) {
router.paramsInheritanceStrategy = opts.paramsInheritanceStrategy;
}
}
}