mirror of
https://github.com/rustfs/console.git
synced 2026-08-29 03:52:28 +08:00
19 lines
613 B
TypeScript
19 lines
613 B
TypeScript
/**
|
|
* Builds the bucket/object path for Next.js navigation (Link, router.push).
|
|
* Returns path WITHOUT basePath - Next.js automatically prepends basePath.
|
|
*/
|
|
export function buildBucketPath(bucketName: string, path?: string | string[]): string {
|
|
if (!bucketName) {
|
|
return "/browser"
|
|
}
|
|
|
|
const params = new URLSearchParams({ bucket: bucketName })
|
|
const pathStr = Array.isArray(path) ? path.join("/") : (path ?? "")
|
|
if (pathStr !== "") {
|
|
const normalizedPath = pathStr.endsWith("/") ? pathStr : `${pathStr}/`
|
|
params.set("key", normalizedPath)
|
|
}
|
|
|
|
return `/browser?${params.toString()}`
|
|
}
|