(headerValue)
| 549 | } |
| 550 | |
| 551 | _getFileName(headerValue) { |
| 552 | // matches either a quoted-string or a token (RFC 2616 section 19.5.1) |
| 553 | const m = headerValue.match( |
| 554 | /\bfilename=("(.*?)"|([^()<>{}[\]@,;:"?=\s/\t]+))($|;\s)/i, |
| 555 | ); |
| 556 | if (!m) return null; |
| 557 | |
| 558 | const match = m[2] || m[3] || ''; |
| 559 | let originalFilename = match.substr(match.lastIndexOf('\\') + 1); |
| 560 | originalFilename = originalFilename.replace(/%22/g, '"'); |
| 561 | originalFilename = originalFilename.replace(/&#([\d]{4});/g, (_, code) => |
| 562 | String.fromCharCode(code), |
| 563 | ); |
| 564 | |
| 565 | return originalFilename; |
| 566 | } |
| 567 | |
| 568 | // able to get composed extension with multiple dots |
| 569 | // "a.b.c" -> ".b.c" |
no outgoing calls
no test coverage detected