Some checks are pending
E2E / Playwright e2e (push) Waiting to run
- Added SessionGuard component to manage session expiration and online status. - Updated AuthProvider to streamline session fetching and handling. - Introduced IdentityProvidersSection for managing OAuth, SAML, and LDAP identity providers. - Implemented identity provider guides for easier configuration. - Enhanced mail settings with infinite scroll option for improved user experience. - Updated global styles and layout components for better consistency across the application.
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
export function buildPublicShareEditHref(
|
|
token: string,
|
|
filePath: string,
|
|
returnTo?: string,
|
|
mode: "edit" | "view" = "edit",
|
|
displayName?: string
|
|
): string {
|
|
const trimmed = filePath.replace(/^\/+|\/+$/g, "")
|
|
const base = `/drive/s/${encodeURIComponent(token)}/edit/${trimmed.split("/").map(encodeURIComponent).join("/")}`
|
|
const params = new URLSearchParams()
|
|
if (returnTo && returnTo.startsWith("/drive/s/")) {
|
|
params.set("returnTo", returnTo)
|
|
}
|
|
if (mode === "view") {
|
|
params.set("mode", "view")
|
|
}
|
|
if (displayName?.trim()) {
|
|
params.set("name", displayName.trim())
|
|
}
|
|
const qs = params.toString()
|
|
return qs ? `${base}?${qs}` : base
|
|
}
|
|
|
|
export function resolvePublicShareEditReturnTo(
|
|
token: string,
|
|
returnTo: string | null | undefined,
|
|
filePath: string
|
|
): string {
|
|
if (returnTo && returnTo.startsWith("/drive/s/")) return returnTo
|
|
const parent = filePath.replace(/\/[^/]+$/, "") || "/"
|
|
const trimmed = parent.replace(/^\/+|\/+$/g, "")
|
|
if (!trimmed) return `/drive/s/${encodeURIComponent(token)}`
|
|
return `/drive/s/${encodeURIComponent(token)}/${trimmed.split("/").map(encodeURIComponent).join("/")}`
|
|
}
|
|
|
|
export function filePathFromPublicEditSegments(
|
|
token: string,
|
|
segments: string[] | undefined
|
|
): string {
|
|
if (!segments?.length) return "/"
|
|
return "/" + segments.map((s) => decodeURIComponent(s)).join("/")
|
|
}
|