24 行
745 B
TypeScript
24 行
745 B
TypeScript
export type PcDetailNavigationState = {
|
|
from?: string;
|
|
};
|
|
|
|
export function buildPcDetailSource(pathname: string, search: string) {
|
|
return `${pathname}${search}`;
|
|
}
|
|
|
|
export function resolvePcDetailSource(value: unknown, currentPath: string) {
|
|
if (typeof value !== "string" || !value.startsWith("/") || value.startsWith("//") || value.includes("#")) {
|
|
return null;
|
|
}
|
|
|
|
const url = new URL(value, "https://hyb-oa.invalid");
|
|
const isReimbursementList = url.pathname === "/reimbursements";
|
|
const isWorkflowTask = /^\/workflow\/tasks\/[^/]+$/.test(url.pathname);
|
|
if (!isReimbursementList && !isWorkflowTask) {
|
|
return null;
|
|
}
|
|
|
|
const source = `${url.pathname}${url.search}`;
|
|
return source === currentPath ? null : source;
|
|
}
|