(file, options)
| 328 | } |
| 329 | |
| 330 | function cleanFileName(file, options) { |
| 331 | let s = String(file); |
| 332 | |
| 333 | if (options.stripQuery) { |
| 334 | s = s.replace(/[?#].*$/, ""); |
| 335 | } |
| 336 | |
| 337 | if (options.dropExtensionUuid) { |
| 338 | s = s.replace( |
| 339 | /^(?:moz|chrome)-extension:\/\/[^/]+\//, |
| 340 | "extension://" |
| 341 | ); |
| 342 | } |
| 343 | |
| 344 | let parts = s.split("/"); |
| 345 | |
| 346 | if (options.pathSegments > 0) { |
| 347 | parts = parts.slice(-options.pathSegments); |
| 348 | } |
| 349 | |
| 350 | if (options.decode) { |
| 351 | parts = parts.map(part => { |
| 352 | try { |
| 353 | return decodeURIComponent(part); |
| 354 | } catch { |
| 355 | return part; |
| 356 | } |
| 357 | }); |
| 358 | } |
| 359 | |
| 360 | s = parts.join("/"); |
| 361 | |
| 362 | return truncateMiddle(s, options.maxUrlLength); |
| 363 | } |
| 364 | |
| 365 | function truncateMiddle(value, max) { |
| 366 | const str = String(value); |
no test coverage detected