11744 emails broken image in emails (#12265)
- refactor file tokens - update file token management - generate one token per file per workspaceId - move token from query params to url path
This commit is contained in:
25
packages/twenty-shared/src/utils/url/buildSignedPath.ts
Normal file
25
packages/twenty-shared/src/utils/url/buildSignedPath.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
|
||||
export const buildSignedPath = ({
|
||||
path,
|
||||
token,
|
||||
}: {
|
||||
path: string;
|
||||
token: string;
|
||||
}) => {
|
||||
if (path.startsWith('https:') || path.startsWith('http:')) {
|
||||
return path;
|
||||
}
|
||||
|
||||
const directories = path.split('/');
|
||||
|
||||
const filename = directories.pop();
|
||||
|
||||
if (!isNonEmptyString(filename)) {
|
||||
throw new Error(
|
||||
`Filename empty: cannot build signed path from folderPath '${path}'`,
|
||||
);
|
||||
}
|
||||
|
||||
return `${directories.join('/')}/${token}/${filename}`;
|
||||
};
|
||||
Reference in New Issue
Block a user