(filename: string)
| 54 | } |
| 55 | |
| 56 | export function getImageDimensionsFromUrl(filename: string): Dimensions | null { |
| 57 | const extension = getExtension(filename) as string; |
| 58 | const underscore = filename.lastIndexOf('_'); |
| 59 | const x = filename.lastIndexOf('x'); |
| 60 | if (underscore === -1 || x === -1) { |
| 61 | return null; |
| 62 | } |
| 63 | if (x < underscore) { |
| 64 | return null; |
| 65 | } |
| 66 | const part = filename.substring( |
| 67 | underscore + 1, |
| 68 | filename.length - extension.length - 1 |
| 69 | ); |
| 70 | const [part1, part2] = part.split('x'); |
| 71 | |
| 72 | const width = Number(part1); |
| 73 | const height = Number(part2); |
| 74 | |
| 75 | if (width && height) { |
| 76 | return { width, height }; |
| 77 | } |
| 78 | |
| 79 | return null; |
| 80 | } |
| 81 | |
| 82 | export async function getFormData(files: File[]) { |
| 83 | const data = new FormData(); |
no test coverage detected