Created
August 8, 2016 20:48
-
-
Save andredublin/70e52258cc5ee85ed0870eb284abec10 to your computer and use it in GitHub Desktop.
checks the extension of a file name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type FileExtension = | |
|PNG | |
|JPG | |
|GIF | |
|RAW | |
|BMP | |
|SVG | |
|PSD | |
type IsImageType = | |
| IsAnImage | |
| IsNotAnImage | |
let (|PNG|JPG|GIF|RAW|BMP|SVG|PSD|) (input : string) = | |
let fileType = input.Split '.' |> Array.last | |
match fileType.ToLower() with | |
| "psd" -> PSD | |
| "svg" -> SVG | |
| "bmp" -> BMP | |
| "raw" -> RAW | |
| "gif" -> GIF | |
| "jpg" -> JPG | |
| "png" -> PNG | |
| _ -> failwith "Unknown file type" | |
let IsImageUrl str = | |
match str with | |
|PNG |JPG |GIF|RAW|BMP|SVG|PSD -> IsAnImage | |
| _ -> IsNotAnImage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment