(types)
| 416 | } |
| 417 | |
| 418 | function commonPrefix(types) { |
| 419 | // Sort types, inspect first/last strings. |
| 420 | types.sort(); |
| 421 | var first = types[0], |
| 422 | last = types[types.length - 1], |
| 423 | n = Math.min(first.length, last.length), |
| 424 | match = ''; |
| 425 | |
| 426 | // Find common prefix. |
| 427 | while (n > 0) { |
| 428 | last = last.substring(0, n--); |
| 429 | if (first.indexOf(last) == 0) { |
| 430 | match = last; |
| 431 | break; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | return match; |
| 436 | } |
| 437 | |
| 438 | var type = 'application/octed-stream'; |
| 439 |