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