import Foundation

enum BundledWebResources {
    static func contents(of filename: String) -> String {
        let name = (filename as NSString).deletingPathExtension
        let ext = (filename as NSString).pathExtension
        guard let url = Bundle.main.url(forResource: name, withExtension: ext)
        else {
            fatalError("Missing bundled web resource: \(filename)")
        }
        do {
            return try String(contentsOf: url, encoding: .utf8)
        } catch {
            fatalError("Failed to read bundled web resource \(filename): \(error)")
        }
    }
}
