(pathOrUrl: string)
| 435 | |
| 436 | // Returns the lowercased file extension from a path or URL |
| 437 | export function getFileExtension(pathOrUrl: string): string { |
| 438 | const noTrailing = pathOrUrl.split(/[?#]/, 1)[0]; |
| 439 | const lastSlash = Math.max( |
| 440 | noTrailing.lastIndexOf("/"), |
| 441 | noTrailing.lastIndexOf("\\"), |
| 442 | ); |
| 443 | const filename = noTrailing.slice(lastSlash + 1); |
| 444 | const lastDot = filename.lastIndexOf("."); |
| 445 | if (lastDot <= 0 || lastDot === filename.length - 1) { |
| 446 | return ""; // No extension |
| 447 | } |
| 448 | return filename.slice(lastDot + 1).toLowerCase(); |
| 449 | } |
| 450 | |
| 451 | export function getSplatFileTypeFromPath( |
| 452 | pathOrUrl: string, |
no outgoing calls
no test coverage detected