25 lines
603 B
TypeScript
25 lines
603 B
TypeScript
![]() |
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
|
||
|
}
|