fix(ui-services): add route type getter
This commit is contained in:
@@ -14,14 +14,18 @@ import { RouteType } from './RouteType'
|
||||
export class RouteParser implements RouteParserInterface {
|
||||
private url: URL
|
||||
private readonly path: string
|
||||
public readonly type: RouteType
|
||||
private readonly parsedType: RouteType
|
||||
private readonly searchParams: URLSearchParams
|
||||
|
||||
constructor(url: string) {
|
||||
this.url = new URL(url)
|
||||
this.path = this.url.pathname
|
||||
this.searchParams = this.url.searchParams
|
||||
this.type = this.parseTypeFromQueryParameters()
|
||||
this.parsedType = this.parseTypeFromQueryParameters()
|
||||
}
|
||||
|
||||
get type(): RouteType {
|
||||
return this.parsedType
|
||||
}
|
||||
|
||||
get subscriptionInviteParams(): SubscriptionInviteParams {
|
||||
@@ -66,7 +70,7 @@ export class RouteParser implements RouteParserInterface {
|
||||
}
|
||||
|
||||
private checkForProperRouteType(type: RouteType): void {
|
||||
if (this.type !== type) {
|
||||
if (this.parsedType !== type) {
|
||||
throw new Error('Accessing invalid params')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { OnboardingParams } from './Params/OnboardingParams'
|
||||
import { PurchaseParams } from './Params/PurchaseParams'
|
||||
import { SettingsParams } from './Params/SettingsParams'
|
||||
import { SubscriptionInviteParams } from './Params/SubscriptionInviteParams'
|
||||
import { RouteType } from './RouteType'
|
||||
|
||||
export interface RouteParserInterface {
|
||||
get demoParams(): DemoParams
|
||||
@@ -10,4 +11,5 @@ export interface RouteParserInterface {
|
||||
get purchaseParams(): PurchaseParams
|
||||
get onboardingParams(): OnboardingParams
|
||||
get subscriptionInviteParams(): SubscriptionInviteParams
|
||||
get type(): RouteType
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user