This repository has been archived by the owner on Apr 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from nodes-vapor/public-interface
Public interface and README
- Loading branch information
Showing
8 changed files
with
180 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
coverage: | ||
range: "80...100" | ||
ignore: | ||
- "Sources/DataURI/Scanner.swift" | ||
- "Sources/Scanner.swift" | ||
- "Sources/DataURI+String.swift" |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Core | ||
import Foundation | ||
|
||
//FIXME(Brett): I patched this into Core 1.1, remove when updated. | ||
extension Sequence where Iterator.Element == Byte { | ||
internal var base64Decoded: Bytes { | ||
let bytes = [Byte](self) | ||
let dataBase64 = Data(bytes: bytes) | ||
guard let data = Data(base64Encoded: dataBase64) else { | ||
return [] | ||
} | ||
|
||
var encodedBytes = Bytes(repeating: 0, count: data.count) | ||
data.copyBytes(to: &encodedBytes, count: data.count) | ||
|
||
return encodedBytes | ||
} | ||
} | ||
|
||
extension String { | ||
/** | ||
Parses a Data URI and returns its type and data. | ||
|
||
- Returns: The type of the file and its data as bytes. | ||
*/ | ||
public func dataURIDecoded() throws -> (type: String, data: Bytes) { | ||
let (type, _, data) = try DataURIParser.parse(uri: self) | ||
return (type.string, data) | ||
} | ||
} |
Empty file.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ import XCTest | |
|
||
XCTMain([ | ||
testCase(DataURITests.allTests), | ||
testCase(ParserTests.allTests), | ||
]) |