15 lines
668 B
TypeScript
15 lines
668 B
TypeScript
|
|
export type VersionFormat = 'docx' | 'pdf'
|
||
|
|
|
||
|
|
export function versionFileName(fileName: string, versionNumber: number, format: VersionFormat = 'docx'): string {
|
||
|
|
return `${fileName.replace(/\.docx$/i, '')}_v${versionNumber}.${format}`
|
||
|
|
}
|
||
|
|
|
||
|
|
export function versionDownloadPath(documentId: string, versionId: string, format: VersionFormat = 'docx'): string {
|
||
|
|
return `/api/documents/${documentId}/versions/${versionId}/download-link${format === 'pdf' ? '?format=pdf' : ''}`
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Office URI Schemes: preserve the signed URL, including its existing percent escapes. */
|
||
|
|
export function wordOpenUrl(presignedUrl: string): string {
|
||
|
|
return `ms-word:ofe|u|${presignedUrl}`
|
||
|
|
}
|