Spaces:
Build error
Build error
File size: 520 Bytes
d9494a5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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}`;
};
|