Dot or Not? A type safety story about file extensions

from blog nickb.dev, | ↗ original
Let’s write a function that takes in a file extension and returns a file type: function fileType(fileExtension: string) { switch (fileExtension) { case ".mp4": return "video"; // ... } } Our function assumes the file extension has a leading dot, but should it? The Python standard library includes the dot in file extensions. Rust takes...