1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 00:12:29 +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 { struct Source {
init(_ argument: String) throws { init(_ argument: String) throws {
URL = NSURL(string: argument) ?? NSURL(fileURLWithPath: argument) let URL = NSURL(string: argument) ?? NSURL(fileURLWithPath: argument)
guard let type = URL.pathExtension else { throw "cannot tell the type of \(URL)" } guard let type = URL.pathExtension ?? URL.fragment else { throw "cannot tell the type of \(URL)" }
self.URL = URL
self.type = type self.type = type
contents = try NSString(contentsOfURL: URL, encoding: NSUTF8StringEncoding) as String contents = try NSString(contentsOfURL: URL, encoding: NSUTF8StringEncoding) as String
} }