(imageName: string)
| 143 | } |
| 144 | |
| 145 | export function getMaskLookupPaths(imageName: string): string[] { |
| 146 | const normalized = normalizeImagePath(imageName); |
| 147 | const replaced = normalized.replace(/\/images\//i, '/masks/').replace(/^images\//i, 'masks/'); |
| 148 | const hasImagesInPath = replaced !== normalized; |
| 149 | const stripped = normalized.replace(/^images\//i, ''); |
| 150 | const maskPath = `masks/${stripped}`; |
| 151 | const filename = normalized.split('/').pop() || ''; |
| 152 | const maskByFilename = `masks/${filename}`; |
| 153 | const tryPaths: string[] = []; |
| 154 | |
| 155 | if (hasImagesInPath) { |
| 156 | tryPaths.push(replaced, `${replaced}.png`); |
| 157 | } |
| 158 | |
| 159 | tryPaths.push(maskPath, `${maskPath}.png`); |
| 160 | |
| 161 | if (maskByFilename !== maskPath) { |
| 162 | tryPaths.push(maskByFilename, `${maskByFilename}.png`); |
| 163 | } |
| 164 | |
| 165 | return tryPaths; |
| 166 | } |
| 167 | |
| 168 | export function getMaskPathVariants(imageName: string): string[] { |
| 169 | const normalized = normalizeImagePath(imageName); |
no test coverage detected