Files
modeling-app/src/lib/createFileLink.ts

25 lines
603 B
TypeScript
Raw Normal View History

2024-10-08 12:32:47 -04:00
import { UnitLength_type } from '@kittycad/lib/dist/types/src/models'
import { CREATE_FILE_URL_PARAM, PROD_APP_URL } from './constants'
import { stringToBase64 } from './base64'
/**
* Given a file's code, name, and units, creates shareable link
* TODO: make the app respect this link
*/
export function createFileLink({
code,
name,
units,
}: {
code: string
name: string
units: UnitLength_type
}) {
return new URL(
`/?${CREATE_FILE_URL_PARAM}&name=${encodeURIComponent(
name
)}&units=${units}&code=${encodeURIComponent(stringToBase64(code))}`,
PROD_APP_URL
).href
}