13 lines
303 B
TypeScript
13 lines
303 B
TypeScript
// 裁剪指定prefix路径
|
|
export function trimPathPrefix(path: string, prefix: string): string {
|
|
return path.startsWith(prefix) ? path.slice(prefix.length) : path
|
|
}
|
|
|
|
export const safeJsonStringify = (obj: any) => {
|
|
try {
|
|
return JSON.stringify(obj)
|
|
} catch (e) {
|
|
return String(obj)
|
|
}
|
|
}
|