(url, prefix)
| 280 | } |
| 281 | |
| 282 | function objectKeyForUrl(url, prefix) { |
| 283 | const parsed = new URL(url); |
| 284 | const basename = sanitizeFileName(path.basename(parsed.pathname)); |
| 285 | const extension = path.extname(basename).toLowerCase(); |
| 286 | const hash = crypto.createHash("sha1").update(url).digest("hex").slice(0, 12); |
| 287 | const fileName = basename && basename.length <= 120 ? `${hash}-${basename}` : `${hash}${extension || ".img"}`; |
| 288 | return `${trimSlashes(prefix)}/${fileName}`; |
| 289 | } |
| 290 | |
| 291 | function sanitizeFileName(fileName) { |
| 292 | const decoded = safeDecodeURIComponent(fileName); |
no test coverage detected