diff --git a/.swift-version b/.swift-version index f2c6cb6..819e07a 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.2.3 +5.0 diff --git a/.travis.yml b/.travis.yml index 1fd5fb0..b54d50d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,17 +25,17 @@ matrix: dist: xenial sudo: required services: docker - env: DOCKER_IMAGE=swift:4.2.3 + env: DOCKER_IMAGE=swift:4.2.4 SWIFT_SNAPSHOT=4.2.4 - os: linux dist: xenial sudo: required services: docker - env: DOCKER_IMAGE=swift:4.2.3 SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT + env: DOCKER_IMAGE=swift:5.0-xenial - os: linux dist: xenial sudo: required services: docker - env: DOCKER_IMAGE=ubuntu:18.04 + env: DOCKER_IMAGE=swift:5.0 SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT - os: osx osx_image: xcode9.2 sudo: required @@ -47,8 +47,12 @@ matrix: - os: osx osx_image: xcode10.1 sudo: required + env: SWIFT_SNAPSHOT=4.2.1 - os: osx - osx_image: xcode10.1 + osx_image: xcode10.2 + sudo: required + - os: osx + osx_image: xcode10.2 sudo: required env: SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT diff --git a/Package.swift b/Package.swift index 84c4e44..e39fefb 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.0 +// swift-tools-version:5.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription diff --git a/Package@swift-4.0.swift b/Package@swift-4.0.swift new file mode 100644 index 0000000..84c4e44 --- /dev/null +++ b/Package@swift-4.0.swift @@ -0,0 +1,28 @@ +// swift-tools-version:4.0 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "KituraContracts", + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "KituraContracts", + targets: ["KituraContracts"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + .package(url:"https://github.com/IBM-Swift/LoggerAPI.git", from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "KituraContracts", + dependencies: ["LoggerAPI"]), + .testTarget( + name: "KituraContractsTests", + dependencies: ["KituraContracts"]), + ] +) diff --git a/Package@swift-4.1.swift b/Package@swift-4.1.swift new file mode 100644 index 0000000..84c4e44 --- /dev/null +++ b/Package@swift-4.1.swift @@ -0,0 +1,28 @@ +// swift-tools-version:4.0 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "KituraContracts", + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "KituraContracts", + targets: ["KituraContracts"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + .package(url:"https://github.com/IBM-Swift/LoggerAPI.git", from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "KituraContracts", + dependencies: ["LoggerAPI"]), + .testTarget( + name: "KituraContractsTests", + dependencies: ["KituraContracts"]), + ] +) diff --git a/Package@swift-4.2.swift b/Package@swift-4.2.swift new file mode 100644 index 0000000..05559bd --- /dev/null +++ b/Package@swift-4.2.swift @@ -0,0 +1,28 @@ +// swift-tools-version:4.2 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "KituraContracts", + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "KituraContracts", + targets: ["KituraContracts"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + .package(url:"https://github.com/IBM-Swift/LoggerAPI.git", from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "KituraContracts", + dependencies: ["LoggerAPI"]), + .testTarget( + name: "KituraContractsTests", + dependencies: ["KituraContracts"]), + ] +) diff --git a/Sources/KituraContracts/Contracts.swift b/Sources/KituraContracts/Contracts.swift index 18d3b18..2a57895 100644 --- a/Sources/KituraContracts/Contracts.swift +++ b/Sources/KituraContracts/Contracts.swift @@ -1021,10 +1021,18 @@ public struct Ordering: Codable { // Function to extract the String value from the Order enum case private func extractValue(_ value: String) throws -> String { +#if swift(>=4.2) + guard var startIndex = value.firstIndex(of: "("), + let endIndex = value.firstIndex(of: ")") else { + throw QueryParamsError.invalidValue + } +#else guard var startIndex = value.index(of: "("), let endIndex = value.index(of: ")") else { throw QueryParamsError.invalidValue } +#endif + startIndex = value.index(startIndex, offsetBy: 1) let extractedValue = value[startIndex..