diff --git a/.travis.yml b/.travis.yml index e806e0f..b1ed834 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,8 @@ os: - linux - - osx language: generic sudo: required dist: trusty -osx_image: xcode8 script: - - eval "$(curl -sL https://swift.vapor.sh/ci)" + - eval "$(curl -sL https://gist.githubusercontent.com/BrettRToomey/1256d98cce5546c696cc68d9f61ad46f/raw/d5fb266a17f26c41b59fd00867a3a2474c3efee3/TravisSwift31)" - eval "$(curl -sL https://swift.vapor.sh/codecov)" diff --git a/Package.swift b/Package.swift index 15136b3..9e1ad8f 100644 --- a/Package.swift +++ b/Package.swift @@ -3,6 +3,6 @@ import PackageDescription let package = Package( name: "DataURI", dependencies: [ - .Package(url: "https://github.com/vapor/core.git", majorVersion: 1), + .Package(url: "https://github.com/vapor/vapor.git", Version(2,0,0, prereleaseIdentifiers: ["beta"])), ] ) diff --git a/Sources/DataURI+String.swift b/Sources/DataURI+String.swift index 9a311dc..7cce709 100644 --- a/Sources/DataURI+String.swift +++ b/Sources/DataURI+String.swift @@ -1,23 +1,6 @@ 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 data and type. @@ -26,6 +9,6 @@ extension String { */ public func dataURIDecoded() throws -> (data: Bytes, type: String) { let (data, type, _) = try DataURIParser.parse(uri: self) - return (data, type.string) + return (data, type.makeString()) } } diff --git a/Tests/DataURITests/DataURITests.swift b/Tests/DataURITests/DataURITests.swift index 4fa6690..07c10f6 100644 --- a/Tests/DataURITests/DataURITests.swift +++ b/Tests/DataURITests/DataURITests.swift @@ -1,5 +1,4 @@ import XCTest - import Core @testable import DataURI @@ -17,9 +16,9 @@ class DataURITests: XCTestCase { func testBase64() { //FIXME(Brett): remove when vapor/core is updated to 1.1 - let base64Bytes = "SGVsbG8sIHdvcmxkIQ==".bytes - let output = base64Bytes.base64Decoded - XCTAssertEqual(output.string, "Hello, world!") + let base64Bytes: Bytes = "SGVsbG8sIHdvcmxkIQ==".makeBytes() + let output: Bytes = base64Bytes.base64URLDecoded + XCTAssertEqual(output.makeString(), "Hello, world!") } func testTextNoType() { @@ -27,8 +26,8 @@ class DataURITests: XCTestCase { uri: "data:,Hello%2C%20World!" ) - XCTAssertEqual(data.string, "Hello, World!") - XCTAssertEqual(type.string, "text/plain;charset=US-ASCII") + XCTAssertEqual(data.makeString(), "Hello, World!") + XCTAssertEqual(type.makeString(), "text/plain;charset=US-ASCII") XCTAssertNil(meta) } @@ -37,9 +36,9 @@ class DataURITests: XCTestCase { uri: "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D" ) - XCTAssertEqual(data.string, "Hello, World!") - XCTAssertEqual(type.string, "text/plain") - XCTAssertEqual(meta?.string, "base64") + XCTAssertEqual(data.makeString(), "Hello, World!") + XCTAssertEqual(type.makeString(), "text/plain") + XCTAssertEqual(meta?.makeString(), "base64") } func testHTMLText() { @@ -47,8 +46,8 @@ class DataURITests: XCTestCase { uri: "data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E" ) - XCTAssertEqual(data.string, "