From 63364713bc267e9ac6cf2d372109535329e6881e Mon Sep 17 00:00:00 2001 From: RazzibShakya <48817591+RazzibShakya@users.noreply.github.com> Date: Thu, 27 Jan 2022 11:49:43 +0545 Subject: [PATCH] Add optional parameter of initialUrl --- src/router/Router.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/router/Router.ts b/src/router/Router.ts index dabef95..afc8450 100644 --- a/src/router/Router.ts +++ b/src/router/Router.ts @@ -42,9 +42,10 @@ export class Router { this.mapUrl = mapUrl; } - setMapUrl = (mapUrl: UrlMapper) => { - if (this.mapUrl) return; - this.mapUrl = mapUrl; + setMapUrl = (mapUrl: UrlMapper, initialUrl?: string) => { + if (this.mapUrl) throw new Error('Url mapper has already been declared'); + this.mapUrl = mapUrl; + if (initialUrl) this.setUrl(initialUrl); }; private getRecentUrl(): string | null {