1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 16:02:43 +03:00

Allow the fragment to specify a type.

This commit is contained in:
Rob Rix 2015-10-30 17:16:02 -04:00
parent ff760d67b3
commit ec579b2053

View File

@ -18,8 +18,9 @@ typealias Parser = String throws -> Term
struct Source {
init(_ argument: String) throws {
URL = NSURL(string: argument) ?? NSURL(fileURLWithPath: argument)
guard let type = URL.pathExtension else { throw "cannot tell the type of \(URL)" }
let URL = NSURL(string: argument) ?? NSURL(fileURLWithPath: argument)
guard let type = URL.pathExtension ?? URL.fragment else { throw "cannot tell the type of \(URL)" }
self.URL = URL
self.type = type
contents = try NSString(contentsOfURL: URL, encoding: NSUTF8StringEncoding) as String
}