feat(platform-web): preserve protocol in vehicle links
This commit is contained in:
@@ -5,6 +5,7 @@ const pageKeys = new Set<PageKey>(['dashboard', 'vehicles', 'realtime', 'detail'
|
||||
export type AppRoute = {
|
||||
page?: PageKey;
|
||||
keyword?: string;
|
||||
protocol?: string;
|
||||
};
|
||||
|
||||
export function parseAppHash(hash: string): AppRoute {
|
||||
@@ -18,7 +19,8 @@ export function parseAppHash(hash: string): AppRoute {
|
||||
}
|
||||
const params = new URLSearchParams(queryPart);
|
||||
const keyword = params.get('keyword')?.trim() || undefined;
|
||||
return { page: pagePart as PageKey, keyword };
|
||||
const protocol = params.get('protocol')?.trim() || undefined;
|
||||
return { page: pagePart as PageKey, keyword, protocol };
|
||||
}
|
||||
|
||||
export function buildAppHash(route: AppRoute): string {
|
||||
@@ -28,6 +30,10 @@ export function buildAppHash(route: AppRoute): string {
|
||||
if (keyword) {
|
||||
params.set('keyword', keyword);
|
||||
}
|
||||
const protocol = route.protocol?.trim();
|
||||
if (protocol) {
|
||||
params.set('protocol', protocol);
|
||||
}
|
||||
const query = params.toString();
|
||||
return query ? `#/${page}?${query}` : `#/${page}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user